-
Notifications
You must be signed in to change notification settings - Fork 1
Changes from all commits
6b114d1
4afcd46
bb8d7e8
34ae2f3
c1f3ac7
5a65e0e
ba8a094
2746f09
c23cc76
0e63709
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,11 +6,13 @@ | |
|
|
||
| import java.io.ByteArrayInputStream; | ||
| import java.io.ByteArrayOutputStream; | ||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.io.InputStreamReader; | ||
| import java.io.OutputStream; | ||
| import java.io.OutputStreamWriter; | ||
| import java.io.RandomAccessFile; | ||
| import java.io.UnsupportedEncodingException; | ||
| import java.io.Writer; | ||
| import java.nio.charset.Charset; | ||
|
|
@@ -198,4 +200,34 @@ static String read(String str, int fromIndexInclude, int toIndexExclude) { | |
|
|
||
| return str.substring(fromIndexInclude, toIndexExclude); | ||
| } | ||
|
|
||
| /** | ||
| * new randomAccessFile. when File not found, then return null. | ||
| * | ||
| * @param filePath filePath | ||
| * @return {@link RandomAccessFile } | ||
| */ | ||
| @Nullable | ||
| static RandomAccessFile newRaf(String filePath) { | ||
| try { | ||
| return new RandomAccessFile(filePath, "r"); | ||
| } catch (Exception e) { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| static File newFile(String filePath) { | ||
| return new File(filePath); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PATH_TRAVERSAL_IN: This API (java/io/File.(Ljava/lang/String;)V) reads a file whose location might be specified by user input (at-me in a reply with Was this a good recommendation? |
||
| } | ||
|
|
||
| /** | ||
| * file to randomAccessFile. when File not found, then return null. | ||
| */ | ||
| static RandomAccessFile toRaf(File file) { | ||
| try { | ||
| return new RandomAccessFile(file, "r"); | ||
| } catch (Exception e) { | ||
| return null; | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package io.github.fzdwx.lambada.anno; | ||
|
|
||
| import java.lang.annotation.Documented; | ||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| /** | ||
| * mark value maybe null.(same as @NonNull) | ||
| * | ||
| * @author <a href="mailto:likelovec@gmail.com">fzdwx</a> | ||
| * @apiNote just mark, no effect. | ||
| * @date 2022/5/16 14:13 | ||
| */ | ||
| @Documented | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target({ | ||
| ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD, | ||
|
|
||
| }) | ||
| public @interface NotNull { } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package io.github.fzdwx.lambada.http; | ||
|
|
||
| import cn.hutool.core.io.FileUtil; | ||
| import cn.hutool.json.JSONArray; | ||
| import cn.hutool.json.JSONObject; | ||
| import cn.hutool.json.JSONUtil; | ||
| import io.github.fzdwx.lambada.Lang; | ||
| import io.github.fzdwx.lambada.Seq; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| class ContentParseParse { | ||
|
|
||
| static Map<String, String> m; | ||
|
|
||
| static { | ||
| final String s = FileUtil.readString("mime.json", Lang.CHARSET); | ||
| final JSONArray array = JSONUtil.parseObj(s).getJSONArray("mime-mapping"); | ||
| m = Seq.toMap(array.stream(), o1 -> ((JSONObject) o1).getStr("extension"), o2 -> ((JSONObject) o2).getStr("mime-type")); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8,23 +8,19 @@ | |||||
| import java.util.Map; | ||||||
|
|
||||||
| /** | ||||||
| * 可排序,不区分大小写(Name value map) | ||||||
| * <p> | ||||||
| * 用于:参数解析,Header,Param 处理 | ||||||
| * | ||||||
| * @see LinkedCaseInsensitiveMap | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MissingSummary: A summary fragment is required; consider using the value of the @see block as a summary fragment instead.
Suggested change
(at-me in a reply with Was this a good recommendation? |
||||||
| */ | ||||||
| public class NvMap extends LinkedCaseInsensitiveMap<String> { | ||||||
| public class KvMap extends LinkedCaseInsensitiveMap<String> { | ||||||
|
|
||||||
| public static NvMap create() { | ||||||
| return new NvMap(); | ||||||
| public static KvMap create() { | ||||||
| return new KvMap(); | ||||||
| } | ||||||
|
|
||||||
| public NvMap() { | ||||||
| public KvMap() { | ||||||
| super(); | ||||||
| } | ||||||
|
|
||||||
| public NvMap(Map<?, ?> map) { | ||||||
| public KvMap(Map<?, ?> map) { | ||||||
| super(); | ||||||
|
|
||||||
| if (map != null) { | ||||||
|
|
@@ -36,17 +32,17 @@ public NvMap(Map<?, ?> map) { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| public NvMap set(String key, String val) { | ||||||
| public KvMap set(String key, String val) { | ||||||
| put(key, val); | ||||||
| return this; | ||||||
| } | ||||||
|
|
||||||
| public static NvMap from(String[] args) { | ||||||
| public static KvMap from(String[] args) { | ||||||
| return from(Arrays.asList(args)); | ||||||
| } | ||||||
|
|
||||||
| public static NvMap from(List<String> args) { | ||||||
| NvMap d = new NvMap(); | ||||||
| public static KvMap from(List<String> args) { | ||||||
| KvMap d = new KvMap(); | ||||||
|
|
||||||
| if (args != null) { | ||||||
| for (String arg : args) { | ||||||
|
|
@@ -63,7 +59,7 @@ public static NvMap from(List<String> args) { | |||||
| return d; | ||||||
| } | ||||||
|
|
||||||
| public NvMap add(final String key, final Iterable<String> value) { | ||||||
| public KvMap add(final String key, final Iterable<String> value) { | ||||||
| for (final String s : value) { | ||||||
| this.put(key, s); | ||||||
| } | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package io.github.fzdwx.lambada.lang; | ||
|
|
||
| /** | ||
| * @author <a href="mailto:likelovec@gmail.com">fzdwx</a> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MissingSummary: A summary line is required on public/protected Javadocs. (at-me in a reply with Was this a good recommendation? |
||
| * @date 2022/5/27 18:08 | ||
| */ | ||
| public class ResourceLoader { | ||
|
|
||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PATH_TRAVERSAL_IN: This API (java/io/RandomAccessFile.(Ljava/lang/String;Ljava/lang/String;)V) reads a file whose location might be specified by user input
(at-me in a reply with
helporignore)Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]