Skip to content

Commit

Permalink
1.5.7
Browse files Browse the repository at this point in the history
Add Stream/IntStream/.../DoubleStream.scan(seed, accumulator, seedIncluded).

Add ByteStream/IntStream/.../DoubleStream.flatMappToObj(ByteFunction<T[]> mapper).

Add PreparedQuery.batchUpdate/batchInsert(PreparedQuery...).

Improvements and bug fix.
  • Loading branch information
landawn committed Mar 17, 2019
1 parent 2ca63c9 commit 63fb690
Show file tree
Hide file tree
Showing 47 changed files with 1,011 additions and 851 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

* Add `ByteStream/IntStream/.../DoubleStream.flatMappToObj(ByteFunction<T[]> mapper)`.

* Add `JdbcUtil.batchUpdate/batchInsert(PreparedQuery...)`.
* Add `PreparedQuery.batchUpdate/batchInsert`.

* Improvements and bug fix.

Expand Down
66 changes: 33 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,33 +182,33 @@ A general programming library in Java/Android. It's easy to learn and simple to
[RemoteExecutor](https://cdn.rawgit.com/landawn/AbacusUtil/master/docs/RemoteExecutor_view.html).

* More:
[Charsets](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/Charsets.html),
[Ascii](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/Ascii.html),
[CalendarUnit](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/CalendarUnit.html),
[NamingPolicy](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/NamingPolicy.html),
[Properties](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/Properties.html),
[PropertiesUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/PropertiesUtil.html),
[Wrapper](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/Wrapper.html),
[ArrayHashSet](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/ArrayHashSet.html),
[ArrayHashMap](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/ArrayHashMap.html),
[ClassUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/ClassUtil.html),
[EscapeUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/EscapeUtil.html),
[RegExUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/RegExUtil.html),
[FilenameUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/FilenameUtil.html),
[AWSJSONUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/AWSJSONUtil.html),
[AddrUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/AddrUtil.html),
[WSSecurityUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/WSSecurityUtil.html),
[EmailUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/EmailUtil.html),
[IEEE754rUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/IEEE754rUtil.html),
[Index](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/Index.html),
[Median](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/Median.html),
[f](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/f.html),
[Iterables](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/Iterables.html),
[Matth](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/Matth.html),
[SafeInitializer](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/SafeInitializer.html),
[Stopwatch](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/Stopwatch.html),
[RateLimiter](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/RateLimiter.html),
[Traverser](https://static.javadoc.io/com.landawn/abacus-util/1.5.6/com/landawn/abacus/util/Traverser.html)(from Apache commons, Google Guava...) ...
[Charsets](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/Charsets.html),
[Ascii](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/Ascii.html),
[CalendarUnit](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/CalendarUnit.html),
[NamingPolicy](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/NamingPolicy.html),
[Properties](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/Properties.html),
[PropertiesUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/PropertiesUtil.html),
[Wrapper](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/Wrapper.html),
[ArrayHashSet](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/ArrayHashSet.html),
[ArrayHashMap](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/ArrayHashMap.html),
[ClassUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/ClassUtil.html),
[EscapeUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/EscapeUtil.html),
[RegExUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/RegExUtil.html),
[FilenameUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/FilenameUtil.html),
[AWSJSONUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/AWSJSONUtil.html),
[AddrUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/AddrUtil.html),
[WSSecurityUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/WSSecurityUtil.html),
[EmailUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/EmailUtil.html),
[IEEE754rUtil](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/IEEE754rUtil.html),
[Index](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/Index.html),
[Median](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/Median.html),
[f](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/f.html),
[Iterables](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/Iterables.html),
[Matth](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/Matth.html),
[SafeInitializer](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/SafeInitializer.html),
[Stopwatch](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/Stopwatch.html),
[RateLimiter](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/RateLimiter.html),
[Traverser](https://static.javadoc.io/com.landawn/abacus-util/1.5.7/com/landawn/abacus/util/Traverser.html)(from Apache commons, Google Guava...) ...


## Download/Installation & [Changes](https://github.com/landawn/AbacusUtil/blob/master/CHANGES.md):
Expand All @@ -218,22 +218,22 @@ A general programming library in Java/Android. It's easy to learn and simple to
* Gradle:
```gradle
// JDK 1.8 or above:
compile 'com.landawn:abacus-util:1.5.6'
compile 'com.landawn:abacus-util:1.5.7'
// JDK 1.7:
compile 'com.landawn:abacus-util-jdk7:1.5.6'
compile 'com.landawn:abacus-util-jdk7:1.5.7'
// Android (Java 1.7):
compile 'abacus-android-jdk7:1.5.6'
compile 'abacus-android-jdk7:1.5.7'
// Android-SE (Java 1.7) - small edition without Stream/Matrix/Sheet/...:
compile 'abacus-android-se-jdk7:1.5.6'
compile 'abacus-android-se-jdk7:1.5.7'
// Android (Java 1.8 or above):
compile 'com.landawn:abacus-android:1.5.6'
compile 'com.landawn:abacus-android:1.5.7'
// Android-SE (Java 1.8 or above) - small edition without Stream/Matrix/Sheet/...:
compile 'com.landawn:abacus-android-se:1.5.6'
compile 'com.landawn:abacus-android-se:1.5.7'
```
### Functional Programming:
(It's very important to learn Lambdas and Stream APIs in Java 8 to get the best user experiences with the APIs provided in AbacusUtil)
Expand Down
Binary file modified docs/Stream.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified lib/abacus-util-1.5.7.jar
Binary file not shown.
Binary file modified lib/abacus-util-jdk7-1.5.7.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/com/landawn/abacus/android/util/SQLiteExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,7 @@ private String parseStringCondition(String expr) {

if (!StringUtil.isAsciiAlpha(word.charAt(0))) {
sb.append(word);
} else if (i < len - 1 && words.get(i + 1).charAt(0) == WD._PARENTHESES_L) {
} else if (SQLParser.isFunctionName(words, len, i)) {
sb.append(word);
} else {
sb.append(formatName(word));
Expand Down
75 changes: 73 additions & 2 deletions src/com/landawn/abacus/http/HTTP.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.nio.charset.Charset;
import java.util.EnumMap;
import java.util.HashMap;
Expand Down Expand Up @@ -245,6 +246,56 @@ public static OutputStream wrapOutputStream(final OutputStream os, final Content
}
}

public static ContentFormat getContentFormat(final HttpURLConnection connection) {
return getContentFormat(connection.getHeaderField(HttpHeaders.Names.CONTENT_TYPE), connection.getHeaderField(HttpHeaders.Names.CONTENT_ENCODING));
}

public static OutputStream getOutputStream(final HttpURLConnection connection, final ContentFormat contentFormat) throws IOException {
return getOutputStream(connection, contentFormat, HTTP.getContentType(contentFormat), HTTP.getContentEncoding(contentFormat));
}

public static OutputStream getOutputStream(final HttpURLConnection connection, final ContentFormat contentFormat, String contentType,
String contentEncoding) throws IOException {

if (N.isNullOrEmpty(contentType) && contentFormat != null) {
contentType = getContentType(contentFormat);
}

if (N.notNullOrEmpty(contentType)) {
connection.setRequestProperty(HttpHeaders.Names.CONTENT_TYPE, contentType);
}

if (N.isNullOrEmpty(contentEncoding) && contentFormat != null) {
contentEncoding = getContentEncoding(contentFormat);
}

if (N.notNullOrEmpty(contentEncoding)) {
connection.setRequestProperty(HttpHeaders.Names.CONTENT_ENCODING, contentEncoding);
}

return wrapOutputStream(connection.getOutputStream(), contentFormat);
}

public static InputStream getInputStream(final HttpURLConnection connection) throws IOException {
return getInputStream(connection, getContentFormat(connection));
}

public static InputStream getInputStream(final HttpURLConnection connection, ContentFormat contentFormat) throws IOException {
return wrapInputStream(connection.getInputStream(), contentFormat);
}

public static InputStream getInputOrErrorStream(final HttpURLConnection connection) throws IOException {
return getInputOrErrorStream(connection, getContentFormat(connection));
}

public static InputStream getInputOrErrorStream(final HttpURLConnection connection, ContentFormat contentFormat) throws IOException {
try {
return wrapInputStream(connection.getInputStream(), contentFormat);
} catch (IOException e) {
return wrapInputStream(connection.getErrorStream(), contentFormat);
}
}

public static void flush(OutputStream os) throws IOException {
if (os instanceof LZ4BlockOutputStream) {
((LZ4BlockOutputStream) os).finish();
Expand All @@ -255,18 +306,38 @@ public static void flush(OutputStream os) throws IOException {
os.flush();
}

static Charset getCharset(Map<String, List<String>> headers) {
public static Charset getCharset(HttpHeaders headers) {
Charset charset = Charsets.UTF_8;

if (headers != null && headers.headerNameSet().contains(HttpHeaders.Names.CONTENT_TYPE)) {
String value = N.stringOf(headers.get(HttpHeaders.Names.CONTENT_TYPE));
if (value.indexOf("charset=") >= 0) {
charset = getCharset(value);
}
}

return charset;
}

public static Charset getCharset(Map<String, List<String>> headers) {
Charset charset = Charsets.UTF_8;

if (headers != null && headers.containsKey(HttpHeaders.Names.CONTENT_TYPE)) {
for (String value : headers.get(HttpHeaders.Names.CONTENT_TYPE)) {
if (value.indexOf("charset=") >= 0) {
charset = Charsets.get(value.substring(value.indexOf("charset=") + "charset=".length()));
charset = getCharset(value);
break;
}
}
}

return charset;
}

private static Charset getCharset(String value) {
int fromIndex = value.indexOf("charset=");
int toIndex = value.indexOf(';', fromIndex);

return Charsets.get(value.substring(fromIndex + "charset=".length(), toIndex > 0 ? toIndex : value.length()));
}
}
Loading

0 comments on commit 63fb690

Please sign in to comment.