Skip to content

Commit e53406f

Browse files
committed
smaller changes e.g. in FilesAndStreams.getString...
1 parent 685f765 commit e53406f

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

src/main/java/net/b07z/sepia/server/core/tools/ClassBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public static void compile(String className, String classCode, File targetFolder
121121
JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, diagnostics, optionList, null, compilationUnits);
122122
if (task.call()){
123123
//Done
124-
Debugger.println("Compiled '" + className + "' to '" + folderOrMemory, 3);
124+
Debugger.println("ClassBuilder - compiled '" + className + "' to '" + folderOrMemory, 3);
125125
}else{
126126
//Error(s)
127127
for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics.getDiagnostics()){

src/main/java/net/b07z/sepia/server/core/tools/FilesAndStreams.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,18 @@ public void run() {
6666
/**
6767
* Collect all data of an InputStream to a string via BufferedReader and InputStreamReader.<br>
6868
* NOTE: Please check correct encoding of stream!
69+
* @param stream - input stream
70+
* @param charset - e.g.: StandardCharsets.UTF_8
71+
* @param lineBreakChar - a character to use for line-breaks, e.g. "\n" or System.lineSeparator()
72+
* @return
73+
* @throws IOException
6974
*/
70-
public static String getStringFromStream(InputStream stream, Charset charset) throws IOException{
75+
public static String getStringFromStream(InputStream stream, Charset charset, String lineBreakChar) throws IOException{
7176
try (BufferedReader in = new BufferedReader(new InputStreamReader(stream, charset))) {
7277
String inputLine;
7378
StringBuilder response = new StringBuilder();
7479
while ((inputLine = in.readLine()) != null) {
75-
response.append(inputLine + System.lineSeparator());
80+
response.append(inputLine + lineBreakChar);
7681
}
7782
return response.toString();
7883
}catch (IOException e){

src/main/java/net/b07z/sepia/server/core/tools/Is.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package net.b07z.sepia.server.core.tools;
22

3-
import java.util.List;
3+
import java.util.Collection;
44
import java.util.Map;
55

66
import org.json.simple.JSONObject;
@@ -53,15 +53,15 @@ public static boolean notNullOrEmptyMap(Map<String, ?> m){
5353
}
5454

5555
/**
56-
* Returns "true" if the list is null or empty.
56+
* Returns "true" if the collection is null or empty.
5757
*/
58-
public static boolean nullOrEmpty(List<?> l){
58+
public static boolean nullOrEmpty(Collection<?> l){
5959
return (l == null || l.isEmpty());
6060
}
6161
/**
62-
* Returns "true" if the list is not null and not empty.
62+
* Returns "true" if the collection is not null and not empty.
6363
*/
64-
public static boolean notNullOrEmpty(List<?> l){
64+
public static boolean notNullOrEmpty(Collection<?> l){
6565
return (l != null && !l.isEmpty());
6666
}
6767
}

src/main/java/net/b07z/sepia/server/core/tools/SandboxClassLoader.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public SandboxClassLoader(File fileOrDir, List<String> blackList) throws Malform
3030
}
3131

3232
@Override
33+
/**
34+
* Loads class with given binary name if not done before and not on blacklist of the sand-box.
35+
*/
3336
public Class<?> loadClass(String name) throws ClassNotFoundException {
3437
//TODO: add a white-list/black-list combo here? Maybe check for package on black-list first then white-list
3538
if (name.contains(".")){

0 commit comments

Comments
 (0)