From 610c23fe8675165fcbd1a3e521d8f58a7a9633d6 Mon Sep 17 00:00:00 2001 From: wentch <22250530@qq.com> Date: Fri, 25 Dec 2015 14:54:16 +0800 Subject: [PATCH] --- android-jdk6-redkale/lib/asm-5.0.4.jar | Bin 53297 -> 0 bytes .../src/java/beans/ConstructorProperties.java | 76 --- .../src/java/lang/FunctionalInterface.java | 68 --- .../src/java/lang/annotation/Repeatable.java | 49 -- .../java/nio/channels/CompletionHandler.java | 66 -- .../src/java/util/function/BiPredicate.java | 54 -- .../src/java/util/function/Consumer.java | 49 -- .../src/java/util/function/Predicate.java | 49 -- .../src/java/util/function/Supplier.java | 49 -- .../src/javax/annotation/Resource.java | 132 ---- .../src/org/redkale/convert/AnyEncoder.java | 41 -- .../src/org/redkale/convert/ArrayDecoder.java | 80 --- .../src/org/redkale/convert/ArrayEncoder.java | 77 --- .../redkale/convert/CollectionDecoder.java | 70 --- .../redkale/convert/CollectionEncoder.java | 66 -- .../src/org/redkale/convert/Convert.java | 27 - .../org/redkale/convert/ConvertColumn.java | 45 -- .../redkale/convert/ConvertColumnEntry.java | 68 --- .../org/redkale/convert/ConvertColumns.java | 25 - .../org/redkale/convert/ConvertEntity.java | 27 - .../org/redkale/convert/ConvertException.java | 29 - .../src/org/redkale/convert/ConvertType.java | 29 - .../src/org/redkale/convert/DeMember.java | 69 --- .../src/org/redkale/convert/Decodeable.java | 28 - .../src/org/redkale/convert/EnMember.java | 77 --- .../src/org/redkale/convert/Encodeable.java | 28 - .../src/org/redkale/convert/Factory.java | 448 -------------- .../src/org/redkale/convert/MapDecoder.java | 79 --- .../src/org/redkale/convert/MapEncoder.java | 63 -- .../org/redkale/convert/ObjectDecoder.java | 237 ------- .../org/redkale/convert/ObjectEncoder.java | 280 --------- .../src/org/redkale/convert/Reader.java | 113 ---- .../src/org/redkale/convert/SimpledCoder.java | 43 -- .../src/org/redkale/convert/Writer.java | 121 ---- .../convert/bson/BsonByteBufferWriter.java | 135 ---- .../org/redkale/convert/bson/BsonConvert.java | 156 ----- .../org/redkale/convert/bson/BsonFactory.java | 63 -- .../org/redkale/convert/bson/BsonReader.java | 324 ---------- .../convert/bson/BsonSimpledCoder.java | 18 - .../org/redkale/convert/bson/BsonWriter.java | 298 --------- .../convert/ext/BigIntegerSimpledCoder.java | 39 -- .../convert/ext/BoolArraySimpledCoder.java | 68 --- .../redkale/convert/ext/BoolSimpledCoder.java | 33 - .../convert/ext/ByteArraySimpledCoder.java | 68 --- .../redkale/convert/ext/ByteSimpledCoder.java | 33 - .../convert/ext/CharArraySimpledCoder.java | 68 --- .../convert/ext/CharSequenceSimpledCoder.java | 30 - .../redkale/convert/ext/CharSimpledCoder.java | 34 -- .../ext/CompletionHandlerSimpledCoder.java | 33 - .../convert/ext/DLongSimpledCoder.java | 42 -- .../redkale/convert/ext/DateSimpledCoder.java | 34 -- .../convert/ext/DoubleArraySimpledCoder.java | 68 --- .../convert/ext/DoubleSimpledCoder.java | 33 - .../redkale/convert/ext/EnumSimpledCoder.java | 45 -- .../convert/ext/FloatArraySimpledCoder.java | 68 --- .../convert/ext/FloatSimpledCoder.java | 33 - .../convert/ext/InetAddressSimpledCoder.java | 71 --- .../convert/ext/IntArraySimpledCoder.java | 68 --- .../redkale/convert/ext/IntSimpledCoder.java | 33 - .../convert/ext/LongArraySimpledCoder.java | 68 --- .../redkale/convert/ext/LongSimpledCoder.java | 34 -- .../convert/ext/NumberSimpledCoder.java | 33 - .../convert/ext/PatternSimpledCoder.java | 39 -- .../convert/ext/ShortArraySimpledCoder.java | 68 --- .../convert/ext/ShortSimpledCoder.java | 33 - .../convert/ext/StringArraySimpledCoder.java | 68 --- .../convert/ext/StringSimpledCoder.java | 33 - .../redkale/convert/ext/TypeSimpledCoder.java | 43 -- .../convert/json/DLongJsonSimpledCoder.java | 34 -- .../json/InetAddressJsonSimpledCoder.java | 69 --- .../convert/json/JsonByteBufferWriter.java | 349 ----------- .../org/redkale/convert/json/JsonConvert.java | 138 ----- .../org/redkale/convert/json/JsonFactory.java | 63 -- .../org/redkale/convert/json/JsonReader.java | 578 ------------------ .../convert/json/JsonSimpledCoder.java | 18 - .../org/redkale/convert/json/JsonWriter.java | 269 -------- .../org/redkale/net/client/HttpClient.java | 102 ---- .../org/redkale/net/client/HttpFactory.java | 80 --- .../redkale/net/client/WebSocketClient.java | 156 ----- .../src/org/redkale/util/AnyValue.java | 446 -------------- .../org/redkale/util/AsmMethodVisitor.java | 151 ----- .../src/org/redkale/util/Attribute.java | 375 ------------ .../src/org/redkale/util/AutoLoad.java | 28 - .../src/org/redkale/util/ByteArray.java | 167 ----- .../src/org/redkale/util/Creator.java | 296 --------- .../src/org/redkale/util/DLong.java | 119 ---- .../src/org/redkale/util/Ignore.java | 28 - .../src/org/redkale/util/LogLevel.java | 25 - .../src/org/redkale/util/Nameable.java | 16 - .../src/org/redkale/util/ObjectPool.java | 101 --- .../src/org/redkale/util/Reproduce.java | 135 ---- .../src/org/redkale/util/ResourceFactory.java | 245 -------- .../src/org/redkale/util/SelectColumn.java | 137 ----- .../src/org/redkale/util/Sheet.java | 90 --- .../src/org/redkale/util/TypeToken.java | 193 ------ .../src/org/redkale/util/Utility.java | 554 ----------------- .../redkale/net/socks/NodeSocksServer.java | 72 --- .../net/socks/SocksConnectServlet.java | 59 -- .../org/redkale/net/socks/SocksContext.java | 45 -- .../net/socks/SocksPrepareServlet.java | 47 -- .../redkale/net/socks/SocksProxyServlet.java | 199 ------ .../org/redkale/net/socks/SocksRequest.java | 93 --- .../org/redkale/net/socks/SocksResponse.java | 35 -- .../org/redkale/net/socks/SocksRunner.java | 236 ------- .../org/redkale/net/socks/SocksServer.java | 64 -- .../org/redkale/net/socks/SocksServlet.java | 29 - .../org/redkale/service/apns/ApnsMessage.java | 94 --- .../org/redkale/service/apns/ApnsPayload.java | 248 -------- .../org/redkale/service/apns/ApnsService.java | 165 ----- .../service/weixin/WeiXinMPService.java | 107 ---- .../service/weixin/WeiXinPayResult.java | 78 --- .../service/weixin/WeiXinPayService.java | 260 -------- .../service/weixin/WeiXinQYMessage.java | 118 ---- .../service/weixin/WeiXinQYService.java | 321 ---------- src-plugin/readme.txt | 1 - 115 files changed, 12309 deletions(-) delete mode 100644 android-jdk6-redkale/lib/asm-5.0.4.jar delete mode 100644 android-jdk6-redkale/src/java/beans/ConstructorProperties.java delete mode 100644 android-jdk6-redkale/src/java/lang/FunctionalInterface.java delete mode 100644 android-jdk6-redkale/src/java/lang/annotation/Repeatable.java delete mode 100644 android-jdk6-redkale/src/java/nio/channels/CompletionHandler.java delete mode 100644 android-jdk6-redkale/src/java/util/function/BiPredicate.java delete mode 100644 android-jdk6-redkale/src/java/util/function/Consumer.java delete mode 100644 android-jdk6-redkale/src/java/util/function/Predicate.java delete mode 100644 android-jdk6-redkale/src/java/util/function/Supplier.java delete mode 100644 android-jdk6-redkale/src/javax/annotation/Resource.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/AnyEncoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ArrayDecoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ArrayEncoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/CollectionDecoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/CollectionEncoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/Convert.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ConvertColumn.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ConvertColumnEntry.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ConvertColumns.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ConvertEntity.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ConvertException.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ConvertType.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/DeMember.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/Decodeable.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/EnMember.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/Encodeable.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/Factory.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/MapDecoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/MapEncoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ObjectDecoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ObjectEncoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/Reader.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/SimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/Writer.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/bson/BsonByteBufferWriter.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/bson/BsonConvert.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/bson/BsonFactory.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/bson/BsonReader.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/bson/BsonSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/bson/BsonWriter.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/BigIntegerSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/BoolArraySimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/BoolSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/ByteArraySimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/ByteSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/CharArraySimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/CharSequenceSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/CharSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/CompletionHandlerSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/DLongSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/DateSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/DoubleArraySimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/DoubleSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/EnumSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/FloatArraySimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/FloatSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/InetAddressSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/IntArraySimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/IntSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/LongArraySimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/LongSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/NumberSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/PatternSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/ShortArraySimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/ShortSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/StringArraySimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/StringSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/ext/TypeSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/json/DLongJsonSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/json/InetAddressJsonSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/json/JsonByteBufferWriter.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/json/JsonConvert.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/json/JsonFactory.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/json/JsonReader.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/json/JsonSimpledCoder.java delete mode 100644 android-jdk6-redkale/src/org/redkale/convert/json/JsonWriter.java delete mode 100644 android-jdk6-redkale/src/org/redkale/net/client/HttpClient.java delete mode 100644 android-jdk6-redkale/src/org/redkale/net/client/HttpFactory.java delete mode 100644 android-jdk6-redkale/src/org/redkale/net/client/WebSocketClient.java delete mode 100644 android-jdk6-redkale/src/org/redkale/util/AnyValue.java delete mode 100644 android-jdk6-redkale/src/org/redkale/util/AsmMethodVisitor.java delete mode 100644 android-jdk6-redkale/src/org/redkale/util/Attribute.java delete mode 100644 android-jdk6-redkale/src/org/redkale/util/AutoLoad.java delete mode 100644 android-jdk6-redkale/src/org/redkale/util/ByteArray.java delete mode 100644 android-jdk6-redkale/src/org/redkale/util/Creator.java delete mode 100644 android-jdk6-redkale/src/org/redkale/util/DLong.java delete mode 100644 android-jdk6-redkale/src/org/redkale/util/Ignore.java delete mode 100644 android-jdk6-redkale/src/org/redkale/util/LogLevel.java delete mode 100644 android-jdk6-redkale/src/org/redkale/util/Nameable.java delete mode 100644 android-jdk6-redkale/src/org/redkale/util/ObjectPool.java delete mode 100644 android-jdk6-redkale/src/org/redkale/util/Reproduce.java delete mode 100644 android-jdk6-redkale/src/org/redkale/util/ResourceFactory.java delete mode 100644 android-jdk6-redkale/src/org/redkale/util/SelectColumn.java delete mode 100644 android-jdk6-redkale/src/org/redkale/util/Sheet.java delete mode 100644 android-jdk6-redkale/src/org/redkale/util/TypeToken.java delete mode 100644 android-jdk6-redkale/src/org/redkale/util/Utility.java delete mode 100644 src-plugin/org/redkale/net/socks/NodeSocksServer.java delete mode 100644 src-plugin/org/redkale/net/socks/SocksConnectServlet.java delete mode 100644 src-plugin/org/redkale/net/socks/SocksContext.java delete mode 100644 src-plugin/org/redkale/net/socks/SocksPrepareServlet.java delete mode 100644 src-plugin/org/redkale/net/socks/SocksProxyServlet.java delete mode 100644 src-plugin/org/redkale/net/socks/SocksRequest.java delete mode 100644 src-plugin/org/redkale/net/socks/SocksResponse.java delete mode 100644 src-plugin/org/redkale/net/socks/SocksRunner.java delete mode 100644 src-plugin/org/redkale/net/socks/SocksServer.java delete mode 100644 src-plugin/org/redkale/net/socks/SocksServlet.java delete mode 100644 src-plugin/org/redkale/service/apns/ApnsMessage.java delete mode 100644 src-plugin/org/redkale/service/apns/ApnsPayload.java delete mode 100644 src-plugin/org/redkale/service/apns/ApnsService.java delete mode 100644 src-plugin/org/redkale/service/weixin/WeiXinMPService.java delete mode 100644 src-plugin/org/redkale/service/weixin/WeiXinPayResult.java delete mode 100644 src-plugin/org/redkale/service/weixin/WeiXinPayService.java delete mode 100644 src-plugin/org/redkale/service/weixin/WeiXinQYMessage.java delete mode 100644 src-plugin/org/redkale/service/weixin/WeiXinQYService.java delete mode 100644 src-plugin/readme.txt diff --git a/android-jdk6-redkale/lib/asm-5.0.4.jar b/android-jdk6-redkale/lib/asm-5.0.4.jar deleted file mode 100644 index cdb283dd7f6d7d420ba0fca8ec23e1f38fc3b7c1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 53297 zcmagFV{~Rg+b$T}wrv|7+kS$MZL^anwrzK8+jcs(ZL_DpnK^6DJM*10wf5TeW8YOj z?z(R7tCZ!yAuvEdU|>K_Lu(~Ja`#LbKtVuAz(7DSKp;RAB-BM1WfUcu6+{$eBqh|; znG__yCqO{_5`QWUuwV@Dq+RlJ2;eB#uDzm5#~_2T&$DnMc-^eSYj$FFBJFK7f+|8B zm^k?Jo@_3T$WQVfBF*+4FIYy3qP=eafEO@tkBW(Rfh{EPST|yZ@iD61a7g)45CSH^ z_UXn}dOF=sX~(6Li<;B}?(s7o%>v32jHKyvq+Y7Tzc<^2 z$fcRE*I!UvLPFFwUx*q?0xJS?D05|h_vrGszdKB`KfZLRnP5mP9fTF*s}mc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AhnL$z0=EuOnwA|1_h_(!x$X?{r(zG-q!sru{FmckT zOrk&x3|HtIO{u$C@!2qX zM(qjy(NpjwadT~&(c`uS|FL$yWv5aGx~p>(F75jzt&>f*O8cEH*O`{o>ErwQL;D7; zvSC+hhvnVijr#nY*8y5ZO-jwh$_#cYFRJu!v1K4mzOrz}bs_NUCwKm_-|T^3p8e~M zk1SHAt}DqYZ*@;B+oWnP*;{riZMrMUkfEM=6}r98AvamCT)Q2qcz%xgUN^k+#gX_2 z^}9M98%{WC@o79ie;JY?B#|I*8t7^IP#BLZj<3NBxD4SHocE*2)F~6PvQ-;3%Iqvv zrdF4zQO!O>I346G-k|@EwiY5khT22*vQ&#rQQ5=E#KQu24{Q zG{^Lg;@36+%WHY6E0C(P>`|kkl%0EWhg?JYs`D@Lb;~6Pt>bZ0JPpD@rj@gY@^E6$ z%w_J-8;VsIBt;{XfJ??j@VqcQH9{}FSYJ}YeH4J8{dC#SF?_w@c!`hXftR<5f{6|_%<}sXv2TgG%>#M(q)7PW?s@V)S9w}0HPryBqO diff --git a/android-jdk6-redkale/src/java/beans/ConstructorProperties.java b/android-jdk6-redkale/src/java/beans/ConstructorProperties.java deleted file mode 100644 index 5ee947c1f..000000000 --- a/android-jdk6-redkale/src/java/beans/ConstructorProperties.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package java.beans; - -import java.lang.annotation.*; -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; - -/** -

An annotation on a constructor that shows how the parameters of - that constructor correspond to the constructed object's getter - methods. For example: - -

-
-   public class Point {
-       @ConstructorProperties({"x", "y"})
-       public Point(int x, int y) {
-           this.x = x;
-           this.y = y;
-       }
-
-       public int getX() {
-           return x;
-       }
-
-       public int getY() {
-           return y;
-       }
-
-       private final int x, y;
-   }
-
-
- - The annotation shows that the first parameter of the constructor - can be retrieved with the {@code getX()} method and the second with - the {@code getY()} method. Since parameter names are not in - general available at runtime, without the annotation there would be - no way to know whether the parameters correspond to {@code getX()} - and {@code getY()} or the other way around. - - @since 1.6 -*/ -@Documented @Target(CONSTRUCTOR) @Retention(RUNTIME) -public @interface ConstructorProperties { - /** -

The getter names.

- @return the getter names corresponding to the parameters in the - annotated constructor. - */ - String[] value(); -} diff --git a/android-jdk6-redkale/src/java/lang/FunctionalInterface.java b/android-jdk6-redkale/src/java/lang/FunctionalInterface.java deleted file mode 100644 index a93ed51f9..000000000 --- a/android-jdk6-redkale/src/java/lang/FunctionalInterface.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package java.lang; - -import java.lang.annotation.*; - -/** - * An informative annotation type used to indicate that an interface - * type declaration is intended to be a functional interface as - * defined by the Java Language Specification. - * - * Conceptually, a functional interface has exactly one abstract - * method. Since {@linkplain java.lang.reflect.Method#isDefault() - * default methods} have an implementation, they are not abstract. If - * an interface declares an abstract method overriding one of the - * public methods of {@code java.lang.Object}, that also does - * not count toward the interface's abstract method count - * since any implementation of the interface will have an - * implementation from {@code java.lang.Object} or elsewhere. - * - *

Note that instances of functional interfaces can be created with - * lambda expressions, method references, or constructor references. - * - *

If a type is annotated with this annotation type, compilers are - * required to generate an error message unless: - * - *

    - *
  • The type is an interface type and not an annotation type, enum, or class. - *
  • The annotated type satisfies the requirements of a functional interface. - *
- * - *

However, the compiler will treat any interface meeting the - * definition of a functional interface as a functional interface - * regardless of whether or not a {@code FunctionalInterface} - * annotation is present on the interface declaration. - * - * @jls 4.3.2. The Class Object - * @jls 9.8 Functional Interfaces - * @jls 9.4.3 Interface Method Body - * @since 1.8 - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface FunctionalInterface {} diff --git a/android-jdk6-redkale/src/java/lang/annotation/Repeatable.java b/android-jdk6-redkale/src/java/lang/annotation/Repeatable.java deleted file mode 100644 index 7a2daa822..000000000 --- a/android-jdk6-redkale/src/java/lang/annotation/Repeatable.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package java.lang.annotation; - -/** - * The annotation type {@code java.lang.annotation.Repeatable} is - * used to indicate that the annotation type whose declaration it - * (meta-)annotates is repeatable. The value of - * {@code @Repeatable} indicates the containing annotation - * type for the repeatable annotation type. - * - * @since 1.8 - * @jls 9.6 Annotation Types - * @jls 9.7 Annotations - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Repeatable { - /** - * Indicates the containing annotation type for the - * repeatable annotation type. - * @return the containing annotation type - */ - Class value(); -} diff --git a/android-jdk6-redkale/src/java/nio/channels/CompletionHandler.java b/android-jdk6-redkale/src/java/nio/channels/CompletionHandler.java deleted file mode 100644 index 2574dbfbf..000000000 --- a/android-jdk6-redkale/src/java/nio/channels/CompletionHandler.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package java.nio.channels; - -/** - * A handler for consuming the result of an asynchronous I/O operation. - * - *

The asynchronous channels defined in this package allow a completion - * handler to be specified to consume the result of an asynchronous operation. - * The {@link #completed completed} method is invoked when the I/O operation - * completes successfully. The {@link #failed failed} method is invoked if the - * I/O operations fails. The implementations of these methods should complete - * in a timely manner so as to avoid keeping the invoking thread from dispatching - * to other completion handlers. - * - * @param The result type of the I/O operation - * @param The type of the object attached to the I/O operation - * - * @since 1.7 - */ - -public interface CompletionHandler { - - /** - * Invoked when an operation has completed. - * - * @param result - * The result of the I/O operation. - * @param attachment - * The object attached to the I/O operation when it was initiated. - */ - void completed(V result, A attachment); - - /** - * Invoked when an operation fails. - * - * @param exc - * The exception to indicate why the I/O operation failed - * @param attachment - * The object attached to the I/O operation when it was initiated. - */ - void failed(Throwable exc, A attachment); -} diff --git a/android-jdk6-redkale/src/java/util/function/BiPredicate.java b/android-jdk6-redkale/src/java/util/function/BiPredicate.java deleted file mode 100644 index 848c8ebf2..000000000 --- a/android-jdk6-redkale/src/java/util/function/BiPredicate.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package java.util.function; - - -/** - * Represents a predicate (boolean-valued function) of two arguments. This is - * the two-arity specialization of {@link Predicate}. - * - *

This is a functional interface - * whose functional method is {@link #test(Object, Object)}. - * - * @param the type of the first argument to the predicate - * @param the type of the second argument the predicate - * - * @see Predicate - * @since 1.8 - */ -@FunctionalInterface -public interface BiPredicate { - - /** - * Evaluates this predicate on the given arguments. - * - * @param t the first input argument - * @param u the second input argument - * @return {@code true} if the input arguments match the predicate, - * otherwise {@code false} - */ - boolean test(T t, U u); - -} diff --git a/android-jdk6-redkale/src/java/util/function/Consumer.java b/android-jdk6-redkale/src/java/util/function/Consumer.java deleted file mode 100644 index 4031d4e0f..000000000 --- a/android-jdk6-redkale/src/java/util/function/Consumer.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package java.util.function; - -/** - * Represents an operation that accepts a single input argument and returns no - * result. Unlike most other functional interfaces, {@code Consumer} is expected - * to operate via side-effects. - * - *

This is a functional interface - * whose functional method is {@link #accept(Object)}. - * - * @param the type of the input to the operation - * - * @since 1.8 - */ -@FunctionalInterface -public interface Consumer { - - /** - * Performs this operation on the given argument. - * - * @param t the input argument - */ - void accept(T t); - -} diff --git a/android-jdk6-redkale/src/java/util/function/Predicate.java b/android-jdk6-redkale/src/java/util/function/Predicate.java deleted file mode 100644 index b76a5a24d..000000000 --- a/android-jdk6-redkale/src/java/util/function/Predicate.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package java.util.function; - -/** - * Represents a predicate (boolean-valued function) of one argument. - * - *

This is a functional interface - * whose functional method is {@link #test(Object)}. - * - * @param the type of the input to the predicate - * - * @since 1.8 - */ -@FunctionalInterface -public interface Predicate { - - /** - * Evaluates this predicate on the given argument. - * - * @param t the input argument - * @return {@code true} if the input argument matches the predicate, - * otherwise {@code false} - */ - boolean test(T t); - -} diff --git a/android-jdk6-redkale/src/java/util/function/Supplier.java b/android-jdk6-redkale/src/java/util/function/Supplier.java deleted file mode 100644 index b87777e88..000000000 --- a/android-jdk6-redkale/src/java/util/function/Supplier.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package java.util.function; - -/** - * Represents a supplier of results. - * - *

There is no requirement that a new or distinct result be returned each - * time the supplier is invoked. - * - *

This is a functional interface - * whose functional method is {@link #get()}. - * - * @param the type of results supplied by this supplier - * - * @since 1.8 - */ -@FunctionalInterface -public interface Supplier { - - /** - * Gets a result. - * - * @return a result - */ - T get(); -} diff --git a/android-jdk6-redkale/src/javax/annotation/Resource.java b/android-jdk6-redkale/src/javax/annotation/Resource.java deleted file mode 100644 index 3b8963bc9..000000000 --- a/android-jdk6-redkale/src/javax/annotation/Resource.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package javax.annotation; - -import java.lang.annotation.*; -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; - -/** - * The Resource annotation marks a resource that is needed - * by the application. This annotation may be applied to an - * application component class, or to fields or methods of the - * component class. When the annotation is applied to a - * field or method, the container will inject an instance - * of the requested resource into the application component - * when the component is initialized. If the annotation is - * applied to the component class, the annotation declares a - * resource that the application will look up at runtime.

- * - * Even though this annotation is not marked Inherited, deployment - * tools are required to examine all superclasses of any component - * class to discover all uses of this annotation in all superclasses. - * All such annotation instances specify resources that are needed - * by the application component. Note that this annotation may - * appear on private fields and methods of superclasses; the container - * is required to perform injection in these cases as well. - * - * @since Common Annotations 1.0 - */ -@Target({TYPE, FIELD, METHOD}) -@Retention(RUNTIME) -public @interface Resource { - /** - * The JNDI name of the resource. For field annotations, - * the default is the field name. For method annotations, - * the default is the JavaBeans property name corresponding - * to the method. For class annotations, there is no default - * and this must be specified. - */ - String name() default ""; - - /** - * The name of the resource that the reference points to. It can - * link to any compatible resource using the global JNDI names. - * - * @since Common Annotations 1.1 - */ - - String lookup() default ""; - - /** - * The Java type of the resource. For field annotations, - * the default is the type of the field. For method annotations, - * the default is the type of the JavaBeans property. - * For class annotations, there is no default and this must be - * specified. - */ - Class type() default java.lang.Object.class; - - /** - * The two possible authentication types for a resource. - */ - enum AuthenticationType { - CONTAINER, - APPLICATION - } - - /** - * The authentication type to use for this resource. - * This may be specified for resources representing a - * connection factory of any supported type, and must - * not be specified for resources of other types. - */ - AuthenticationType authenticationType() default AuthenticationType.CONTAINER; - - /** - * Indicates whether this resource can be shared between - * this component and other components. - * This may be specified for resources representing a - * connection factory of any supported type, and must - * not be specified for resources of other types. - */ - boolean shareable() default true; - - /** - * A product specific name that this resource should be mapped to. - * The name of this resource, as defined by the name - * element or defaulted, is a name that is local to the application - * component using the resource. (It's a name in the JNDI - * java:comp/env namespace.) Many application servers - * provide a way to map these local names to names of resources - * known to the application server. This mapped name is often a - * global JNDI name, but may be a name of any form.

- * - * Application servers are not required to support any particular - * form or type of mapped name, nor the ability to use mapped names. - * The mapped name is product-dependent and often installation-dependent. - * No use of a mapped name is portable. - */ - String mappedName() default ""; - - /** - * Description of this resource. The description is expected - * to be in the default language of the system on which the - * application is deployed. The description can be presented - * to the Deployer to help in choosing the correct resource. - */ - String description() default ""; -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/AnyEncoder.java b/android-jdk6-redkale/src/org/redkale/convert/AnyEncoder.java deleted file mode 100644 index c99d155c2..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/AnyEncoder.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import java.lang.reflect.Type; - -/** - * 对不明类型的对象进行序列化; BSON序列化时将对象的类名写入Writer,JSON则不写入。 - * - * @see http://www.redkale.org - * @author zhangjx - * @param - */ -public final class AnyEncoder implements Encodeable { - - final Factory factory; - - AnyEncoder(Factory factory) { - this.factory = factory; - } - - @Override - @SuppressWarnings("unchecked") - public void convertTo(final Writer out, final T value) { - if (value == null) { - out.writeNull(); - } else { - out.wirteClassName(factory.getEntity(value.getClass())); - factory.loadEncoder(value.getClass()).convertTo(out, value); - } - } - - @Override - public Type getType() { - return Object.class; - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ArrayDecoder.java b/android-jdk6-redkale/src/org/redkale/convert/ArrayDecoder.java deleted file mode 100644 index 2d7541ac8..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ArrayDecoder.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import java.lang.reflect.*; -import java.util.*; - -/** - * 对象数组的序列化,不包含int[]、long[]这样的primitive class数组. - * 数组长度不能超过 32767。 在BSON中数组长度设定的是short,对于大于32767长度的数组传输会影响性能,所以没有采用int存储。 - * 支持一定程度的泛型。 - * - * @see http://www.redkale.org - * @author zhangjx - * @param - */ -@SuppressWarnings("unchecked") -public final class ArrayDecoder implements Decodeable { - - private final Type type; - - private final Type componentType; - - private final Class componentClass; - - private final Decodeable decoder; - - public ArrayDecoder(final Factory factory, final Type type) { - this.type = type; - if (type instanceof GenericArrayType) { - Type t = ((GenericArrayType) type).getGenericComponentType(); - this.componentType = t instanceof TypeVariable ? Object.class : t; - } else if ((type instanceof Class) && ((Class) type).isArray()) { - this.componentType = ((Class) type).getComponentType(); - } else { - throw new ConvertException("(" + type + ") is not a array type"); - } - if (this.componentType instanceof ParameterizedType) { - this.componentClass = (Class) ((ParameterizedType) this.componentType).getRawType(); - } else { - this.componentClass = (Class) this.componentType; - } - factory.register(type, this); - this.decoder = factory.loadDecoder(this.componentType); - } - - @Override - public T[] convertFrom(Reader in) { - final int len = in.readArrayB(); - if (len == Reader.SIGN_NULL) return null; - final Decodeable localdecoder = this.decoder; - final List result = new ArrayList(); - if (len == Reader.SIGN_NOLENGTH) { - while (in.hasNext()) { - result.add(localdecoder.convertFrom(in)); - } - } else { - for (int i = 0; i < len; i++) { - result.add(localdecoder.convertFrom(in)); - } - } - in.readArrayE(); - T[] rs = (T[]) Array.newInstance((Class) this.componentClass, result.size()); - return result.toArray(rs); - } - - @Override - public String toString() { - return this.getClass().getSimpleName() + "{componentType:" + this.componentType + ", decoder:" + this.decoder + "}"; - } - - @Override - public Type getType() { - return type; - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ArrayEncoder.java b/android-jdk6-redkale/src/org/redkale/convert/ArrayEncoder.java deleted file mode 100644 index 7d81386cd..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ArrayEncoder.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import java.lang.reflect.*; - -/** - * 对象数组的反序列化,不包含int[]、long[]这样的primitive class数组. - * 数组长度不能超过 32767。 在BSON中数组长度设定的是short,对于大于32767长度的数组传输会影响性能,所以没有必要采用int存储。 - * 支持一定程度的泛型。 - * - * @see http://www.redkale.org - * @author zhangjx - * @param - */ -@SuppressWarnings("unchecked") -public final class ArrayEncoder implements Encodeable { - - private final Type type; - - private final Type componentType; - - private final Encodeable anyEncoder; - - private final Encodeable encoder; - - public ArrayEncoder(final Factory factory, final Type type) { - this.type = type; - if (type instanceof GenericArrayType) { - Type t = ((GenericArrayType) type).getGenericComponentType(); - this.componentType = t instanceof TypeVariable ? Object.class : t; - } else if ((type instanceof Class) && ((Class) type).isArray()) { - this.componentType = ((Class) type).getComponentType(); - } else { - throw new ConvertException("(" + type + ") is not a array type"); - } - factory.register(type, this); - this.encoder = factory.loadEncoder(this.componentType); - this.anyEncoder = factory.getAnyEncoder(); - } - - @Override - public void convertTo(Writer out, T[] value) { - if (value == null) { - out.wirteClassName(null); - out.writeNull(); - return; - } - if (value.length == 0) { - out.writeArrayB(0); - out.writeArrayE(); - return; - } - out.writeArrayB(value.length); - final Type comp = this.componentType; - boolean first = true; - for (Object v : value) { - if (!first) out.writeArrayMark(); - ((v != null && v.getClass() == comp) ? encoder : anyEncoder).convertTo(out, v); - if (first) first = false; - } - out.writeArrayE(); - } - - @Override - public String toString() { - return this.getClass().getSimpleName() + "{componentType:" + this.componentType + ", encoder:" + this.encoder + "}"; - } - - @Override - public Type getType() { - return type; - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/CollectionDecoder.java b/android-jdk6-redkale/src/org/redkale/convert/CollectionDecoder.java deleted file mode 100644 index 073794650..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/CollectionDecoder.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import org.redkale.util.Creator; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.Collection; - -/** - * 对象集合的反序列化. - * 集合大小不能超过 32767。 在BSON中集合大小设定的是short,对于大于32767长度的集合传输会影响性能,所以没有采用int存储。 - * 支持一定程度的泛型。 - * - * @see http://www.redkale.org - * @author zhangjx - * @param - */ -@SuppressWarnings("unchecked") -public final class CollectionDecoder implements Decodeable> { - - private final Type type; - - private final Type componentType; - - protected Creator> creator; - - private final Decodeable decoder; - - public CollectionDecoder(final Factory factory, final Type type) { - this.type = type; - if (type instanceof ParameterizedType) { - final ParameterizedType pt = (ParameterizedType) type; - this.componentType = pt.getActualTypeArguments()[0]; - this.creator = factory.loadCreator((Class) pt.getRawType()); - factory.register(type, this); - this.decoder = factory.loadDecoder(this.componentType); - } else { - throw new ConvertException("collectiondecoder not support the type (" + type + ")"); - } - } - - @Override - public Collection convertFrom(Reader in) { - final int len = in.readArrayB(); - if (len == Reader.SIGN_NULL) return null; - final Decodeable localdecoder = this.decoder; - final Collection result = this.creator.create(); - if (len == Reader.SIGN_NOLENGTH) { - while (in.hasNext()) { - result.add(localdecoder.convertFrom(in)); - } - } else { - for (int i = 0; i < len; i++) { - result.add(localdecoder.convertFrom(in)); - } - } - in.readArrayE(); - return result; - } - - @Override - public Type getType() { - return type; - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/CollectionEncoder.java b/android-jdk6-redkale/src/org/redkale/convert/CollectionEncoder.java deleted file mode 100644 index 46d901068..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/CollectionEncoder.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import java.lang.reflect.*; -import java.util.Collection; - -/** - * 对象集合的序列化. - * 集合大小不能超过 32767。 在BSON中集合大小设定的是short,对于大于32767长度的集合传输会影响性能,所以没有采用int存储。 - * 支持一定程度的泛型。 - * - * @see http://www.redkale.org - * @author zhangjx - * @param - */ -@SuppressWarnings("unchecked") -public final class CollectionEncoder implements Encodeable> { - - private final Type type; - - private final Encodeable encoder; - - public CollectionEncoder(final Factory factory, final Type type) { - this.type = type; - if (type instanceof ParameterizedType) { - Type t = ((ParameterizedType) type).getActualTypeArguments()[0]; - if (t instanceof TypeVariable) { - this.encoder = factory.getAnyEncoder(); - } else { - this.encoder = factory.loadEncoder(t); - } - } else { - this.encoder = factory.getAnyEncoder(); - } - } - - @Override - public void convertTo(Writer out, Collection value) { - if (value == null) { - out.writeNull(); - return; - } - if (value.isEmpty()) { - out.writeArrayB(0); - out.writeArrayE(); - return; - } - out.writeArrayB(value.size()); - boolean first = true; - for (Object v : value) { - if (!first) out.writeArrayMark(); - encoder.convertTo(out, v); - if (first) first = false; - } - out.writeArrayE(); - } - - @Override - public Type getType() { - return type; - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/Convert.java b/android-jdk6-redkale/src/org/redkale/convert/Convert.java deleted file mode 100644 index f63681e23..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/Convert.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -/** - * 序列化操作类 - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public abstract class Convert { - - protected final Factory factory; - - protected Convert(Factory factory) { - this.factory = factory; - } - - public Factory getFactory() { - return this.factory; - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ConvertColumn.java b/android-jdk6-redkale/src/org/redkale/convert/ConvertColumn.java deleted file mode 100644 index 336734898..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ConvertColumn.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import java.lang.annotation.*; -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; - -/** - * 依附在setter、getter方法、字段进行简单的配置 - * - * @see http://www.redkale.org - * @author zhangjx - */ -@Inherited -@Documented -@Target({METHOD, FIELD}) -@Retention(RUNTIME) -@Repeatable(ConvertColumns.class) -public @interface ConvertColumn { - - /** - * 给字段取个别名, 只对JSON有效 - * - * @return - */ - String name() default ""; - - /** - * 解析/序列化时是否屏蔽该字段 - * - * @return - */ - boolean ignore() default false; - - /** - * 解析/序列化定制化的TYPE - * - * @return - */ - ConvertType type() default ConvertType.ALL; -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ConvertColumnEntry.java b/android-jdk6-redkale/src/org/redkale/convert/ConvertColumnEntry.java deleted file mode 100644 index 08bbe6d70..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ConvertColumnEntry.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -/** - * ConvertColumn 对应的实体类 - * - * @see http://www.redkale.org - * @author zhangjx - */ -public final class ConvertColumnEntry { - - private String name = ""; - - private boolean ignore; - - private ConvertType convertType; - - public ConvertColumnEntry() { - } - - public ConvertColumnEntry(ConvertColumn column) { - if (column == null) return; - this.name = column.name(); - this.ignore = column.ignore(); - this.convertType = column.type(); - } - - public ConvertColumnEntry(String name, boolean ignore) { - this.name = name; - this.ignore = ignore; - this.convertType = ConvertType.ALL; - } - - public ConvertColumnEntry(String name, boolean ignore, ConvertType convertType) { - this.name = name; - this.ignore = ignore; - this.convertType = convertType; - } - - public String name() { - return name == null ? "" : name; - } - - public void setName(String name) { - this.name = name; - } - - public boolean ignore() { - return ignore; - } - - public void setIgnore(boolean ignore) { - this.ignore = ignore; - } - - public ConvertType type() { - return convertType == null ? ConvertType.ALL : convertType; - } - - public void setConvertType(ConvertType convertType) { - this.convertType = convertType; - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ConvertColumns.java b/android-jdk6-redkale/src/org/redkale/convert/ConvertColumns.java deleted file mode 100644 index 1c62d5539..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ConvertColumns.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import java.lang.annotation.*; -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; - -/** - * ConvertColumn 的多用类 - * - * @see http://www.redkale.org - * @author zhangjx - */ -@Inherited -@Documented -@Target({METHOD, FIELD}) -@Retention(RUNTIME) -public @interface ConvertColumns { - - ConvertColumn[] value(); -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ConvertEntity.java b/android-jdk6-redkale/src/org/redkale/convert/ConvertEntity.java deleted file mode 100644 index f79d71a2f..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ConvertEntity.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import java.lang.annotation.*; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * 用于类名的别名, 类似javax.persistence.Table - * 该值必须是全局唯一 - * 使用场景: 当BSON序列化为了不指定class可以使用@ConvertEntity来取个别名。关联方法: Reader.readClassName() 和 Writer.wirteClassName(String value) 。 - * - * @see http://www.redkale.org - * @author zhangjx - */ -@Inherited -@Documented -@Target({TYPE}) -@Retention(RUNTIME) -public @interface ConvertEntity { - - String value(); -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ConvertException.java b/android-jdk6-redkale/src/org/redkale/convert/ConvertException.java deleted file mode 100644 index 0d45e0829..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ConvertException.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public class ConvertException extends RuntimeException { - - public ConvertException() { - super(); - } - - public ConvertException(String s) { - super(s); - } - - public ConvertException(String message, Throwable cause) { - super(message, cause); - } - - public ConvertException(Throwable cause) { - super(cause); - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ConvertType.java b/android-jdk6-redkale/src/org/redkale/convert/ConvertType.java deleted file mode 100644 index 15d0833c5..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ConvertType.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public enum ConvertType { - - JSON(1), - BSON(2), - ALL(127); - - private final int value; - - private ConvertType(int v) { - this.value = v; - } - - public boolean contains(ConvertType type) { - if (type == null) return false; - return this.value >= type.value && (this.value & type.value) > 0; - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/DeMember.java b/android-jdk6-redkale/src/org/redkale/convert/DeMember.java deleted file mode 100644 index 4f94b28a1..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/DeMember.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import org.redkale.util.Attribute; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - * @param - */ -@SuppressWarnings("unchecked") -public final class DeMember implements Comparable> { - - protected final Attribute attribute; - - protected Decodeable decoder; - - public DeMember(final Attribute attribute) { - this.attribute = attribute; - } - - public DeMember(Attribute attribute, Decodeable decoder) { - this(attribute); - this.decoder = decoder; - } - - public final void read(R in, T obj) { - this.attribute.set(obj, decoder.convertFrom(in)); - } - - public final F read(R in) { - return decoder.convertFrom(in); - } - - public Attribute getAttribute() { - return this.attribute; - } - - @Override - public final int compareTo(DeMember o) { - if (o == null) return 1; - return this.attribute.field().compareTo(o.attribute.field()); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (!(obj instanceof DeMember)) return false; - DeMember other = (DeMember) obj; - return compareTo(other) == 0; - } - - @Override - public int hashCode() { - return this.attribute.field().hashCode(); - } - - @Override - public String toString() { - return "DeMember{" + "attribute=" + attribute.field() + ", decoder=" + decoder + '}'; - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/Decodeable.java b/android-jdk6-redkale/src/org/redkale/convert/Decodeable.java deleted file mode 100644 index 6dbc8458b..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/Decodeable.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import java.lang.reflect.Type; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public interface Decodeable { - - public T convertFrom(final R in); - - /** - * 泛型映射接口 - * - * @return - */ - public Type getType(); - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/EnMember.java b/android-jdk6-redkale/src/org/redkale/convert/EnMember.java deleted file mode 100644 index 99f2cd667..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/EnMember.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import org.redkale.util.Attribute; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - * @param - */ -@SuppressWarnings("unchecked") -public final class EnMember implements Comparable> { - - private final Attribute attribute; - - final Encodeable encoder; - - private final boolean istring; - - //private final boolean isnumber; - private final boolean isbool; - - public EnMember(Attribute attribute, Encodeable encoder) { - this.attribute = attribute; - this.encoder = encoder; - Class t = attribute.type(); - this.istring = CharSequence.class.isAssignableFrom(t); - this.isbool = t == Boolean.class || t == boolean.class; - //this.isnumber = Number.class.isAssignableFrom(t) || (!this.isbool && t.isPrimitive()); - } - - public boolean write(final W out, final boolean comma, final T obj) { - F value = attribute.get(obj); - if (value == null) return comma; - if (out.isTiny()) { - if (istring) { - if (((CharSequence) value).length() == 0) return comma; - } else if (isbool) { - if (!((Boolean) value)) return comma; - } - } - out.writeField(comma, attribute); - encoder.convertTo(out, value); - return true; - } - - @Override - public final int compareTo(EnMember o) { - if (o == null) return 1; - return this.attribute.field().compareTo(o.attribute.field()); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (!(obj instanceof EnMember)) return false; - EnMember other = (EnMember) obj; - return compareTo(other) == 0; - } - - @Override - public int hashCode() { - return this.attribute.field().hashCode(); - } - - @Override - public String toString() { - return "EnMember{" + "attribute=" + attribute.field() + ", encoder=" + encoder + '}'; - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/Encodeable.java b/android-jdk6-redkale/src/org/redkale/convert/Encodeable.java deleted file mode 100644 index 4b95c8d01..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/Encodeable.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import java.lang.reflect.Type; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public interface Encodeable { - - public void convertTo(final W out, T value); - - /** - * 泛型映射接口 - * - * @return - */ - public Type getType(); - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/Factory.java b/android-jdk6-redkale/src/org/redkale/convert/Factory.java deleted file mode 100644 index 5e836bdc8..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/Factory.java +++ /dev/null @@ -1,448 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import java.lang.reflect.Type; -import java.util.Collection; -import java.util.Map; -import java.lang.reflect.*; -import java.math.BigInteger; -import java.net.*; -import java.nio.channels.*; -import static org.redkale.convert.ext.InetAddressSimpledCoder.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.regex.*; -import org.redkale.convert.ext.*; -import org.redkale.util.*; -import org.redkale.util.Creator.Creators; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -@SuppressWarnings("unchecked") -public abstract class Factory { - - private final Factory parent; - - protected Convert convert; - - protected boolean tiny; - - private final Encodeable anyEncoder = new AnyEncoder(this); - - //----------------------------------------------------------------------------------- - private final ConcurrentHashMap creators = new ConcurrentHashMap(); - - private final Map entitys = new ConcurrentHashMap(); - - private final ConcurrentHashMap> decoders = new ConcurrentHashMap(); - - private final ConcurrentHashMap> encoders = new ConcurrentHashMap(); - - private final HashMap columnEntrys = new HashMap(); - - private final Set skipIgnores = new HashSet(); - - private boolean skipAllIgnore = false; - - protected Factory(Factory parent, boolean tiny) { - this.tiny = tiny; - this.parent = parent; - if (parent == null) { - //--------------------------------------------------------- - this.register(boolean.class, BoolSimpledCoder.instance); - this.register(Boolean.class, BoolSimpledCoder.instance); - - this.register(byte.class, ByteSimpledCoder.instance); - this.register(Byte.class, ByteSimpledCoder.instance); - - this.register(short.class, ShortSimpledCoder.instance); - this.register(Short.class, ShortSimpledCoder.instance); - - this.register(char.class, CharSimpledCoder.instance); - this.register(Character.class, CharSimpledCoder.instance); - - this.register(int.class, IntSimpledCoder.instance); - this.register(Integer.class, IntSimpledCoder.instance); - - this.register(long.class, LongSimpledCoder.instance); - this.register(Long.class, LongSimpledCoder.instance); - - this.register(float.class, FloatSimpledCoder.instance); - this.register(Float.class, FloatSimpledCoder.instance); - - this.register(double.class, DoubleSimpledCoder.instance); - this.register(Double.class, DoubleSimpledCoder.instance); - - this.register(Number.class, NumberSimpledCoder.instance); - this.register(String.class, StringSimpledCoder.instance); - this.register(CharSequence.class, CharSequenceSimpledCoder.instance); - this.register(java.util.Date.class, DateSimpledCoder.instance); - this.register(BigInteger.class, BigIntegerSimpledCoder.instance); - this.register(InetAddress.class, InetAddressSimpledCoder.instance); - this.register(DLong.class, DLongSimpledCoder.instance); - this.register(Class.class, TypeSimpledCoder.instance); - this.register(InetSocketAddress.class, InetSocketAddressSimpledCoder.instance); - this.register(Pattern.class, PatternSimpledCoder.instance); - this.register(CompletionHandler.class, CompletionHandlerSimpledCoder.instance); - //--------------------------------------------------------- - this.register(boolean[].class, BoolArraySimpledCoder.instance); - this.register(byte[].class, ByteArraySimpledCoder.instance); - this.register(short[].class, ShortArraySimpledCoder.instance); - this.register(char[].class, CharArraySimpledCoder.instance); - this.register(int[].class, IntArraySimpledCoder.instance); - this.register(long[].class, LongArraySimpledCoder.instance); - this.register(float[].class, FloatArraySimpledCoder.instance); - this.register(double[].class, DoubleArraySimpledCoder.instance); - this.register(String[].class, StringArraySimpledCoder.instance); - //--------------------------------------------------------- - } - } - - public Factory parent() { - return this.parent; - } - - public abstract ConvertType getConvertType(); - - public abstract boolean isReversible(); - - public abstract Factory createChild(); - - public abstract Factory createChild(boolean tiny); - - public Convert getConvert() { - return convert; - } - - public void setTiny(boolean tiny) { - this.tiny = tiny; - } - - public ConvertColumnEntry findRef(AccessibleObject field) { - if (field == null) return null; - ConvertColumnEntry en = this.columnEntrys.get(field); - if (en != null) return en; - final ConvertType ct = this.getConvertType(); - final ConvertColumns ccs = field.getAnnotation(ConvertColumns.class); - final ConvertColumn cc = field.getAnnotation(ConvertColumn.class); - if (ccs == null && cc == null) return null; - final ConvertColumn[] cca = (ccs == null) ? new ConvertColumn[]{cc} : ccs.value(); - for (ConvertColumn ref : cca) { - if (ref.type().contains(ct)) { - ConvertColumnEntry entry = new ConvertColumnEntry(ref); - if (skipAllIgnore) { - entry.setIgnore(false); - return entry; - } - if (skipIgnores.isEmpty()) return entry; - if (skipIgnores.contains(((Member) field).getDeclaringClass())) entry.setIgnore(false); - return entry; - } - } - return null; - } - - final String getEntity(Class clazz) { - ConvertEntity ce = (ConvertEntity) clazz.getAnnotation(ConvertEntity.class); - if (ce != null && findEntity(ce.value()) == null) entitys.put(ce.value(), clazz); - return ce == null ? clazz.getName() : ce.value(); - } - - private Class findEntity(String name) { - Class clazz = entitys.get(name); - return parent == null ? clazz : parent.findEntity(name); - } - - final Class getEntity(String name) { - Class clazz = findEntity(name); - try { - return clazz == null ? Class.forName(name) : clazz; - } catch (Exception ex) { - throw new ConvertException("convert entity is " + name, ex); - } - } - - /** - * 使所有类的所有被声明为ConvertColumn.ignore = true 的字段或方法变为ConvertColumn.ignore = false - *

- * @param skipIgnore - */ - public final void registerSkipAllIgnore(final boolean skipIgnore) { - this.skipAllIgnore = skipIgnore; - } - - /** - * 使该类所有被声明为ConvertColumn.ignore = true 的字段或方法变为ConvertColumn.ignore = false - *

- * @param type - */ - public final void registerSkipIgnore(final Class type) { - skipIgnores.add(type); - } - - public final void register(final Class type, boolean ignore, String... columns) { - for (String column : columns) { - register(type, column, new ConvertColumnEntry(column, ignore)); - } - } - - public final boolean register(final Class type, String column, ConvertColumnEntry entry) { - if (type == null || column == null || entry == null) return false; - try { - final Field field = type.getDeclaredField(column); - String get = "get"; - if (field.getType() == boolean.class || field.getType() == Boolean.class) get = "is"; - char[] cols = column.toCharArray(); - cols[0] = Character.toUpperCase(cols[0]); - String col2 = new String(cols); - try { - register(type.getMethod(get + col2), entry); - } catch (Exception ex) { - } - try { - register(type.getMethod("set" + col2, field.getType()), entry); - } catch (Exception ex) { - } - return register(field, entry); - } catch (Exception e) { - return false; - } - } - - public final boolean register(final AccessibleObject field, final ConvertColumnEntry entry) { - if (field == null || entry == null) return false; - this.columnEntrys.put(field, entry); - return true; - } - - public final void register(final Class clazz, final Creator creator) { - creators.put(clazz, creator); - } - - public final Creator findCreator(Class type) { - Creator creator = creators.get(type); - if (creator != null) return creator; - return this.parent == null ? null : this.parent.findCreator(type); - } - - public final Creator loadCreator(Class type) { - Creator result = findCreator(type); - if (result == null) { - result = Creators.create(type); - creators.put(type, result); - } - return result; - } - - //---------------------------------------------------------------------- - public final Encodeable getAnyEncoder() { - return (Encodeable) anyEncoder; - } - - public final void register(final Type clazz, final SimpledCoder coder) { - decoders.put(clazz, coder); - encoders.put(clazz, coder); - } - - public final void register(final Type clazz, final Decodeable decoder) { - decoders.put(clazz, decoder); - } - - public final void register(final Type clazz, final Encodeable printer) { - encoders.put(clazz, printer); - } - - public final Decodeable findDecoder(final Type type) { - Decodeable rs = (Decodeable) decoders.get(type); - if (rs != null) return rs; - return this.parent == null ? null : this.parent.findDecoder(type); - } - - public final Encodeable findEncoder(final Type type) { - Encodeable rs = (Encodeable) encoders.get(type); - if (rs != null) return rs; - return this.parent == null ? null : this.parent.findEncoder(type); - } - - public final Decodeable loadDecoder(final Type type) { - Decodeable decoder = findDecoder(type); - if (decoder != null) return decoder; - if (type instanceof GenericArrayType) return new ArrayDecoder(this, type); - Class clazz; - if (type instanceof ParameterizedType) { - final ParameterizedType pts = (ParameterizedType) type; - clazz = (Class) (pts).getRawType(); - } else if (type instanceof TypeVariable) { // e.g. - final TypeVariable tv = (TypeVariable) type; - Class cz = tv.getBounds().length == 0 ? Object.class : null; - for (Type f : tv.getBounds()) { - if (f instanceof Class) { - cz = (Class) f; - break; - } - } - clazz = cz; - if (cz == null) throw new ConvertException("not support the type (" + type + ")"); - } else if (type instanceof WildcardType) { // e.g. - final WildcardType wt = (WildcardType) type; - Class cz = null; - for (Type f : wt.getUpperBounds()) { - if (f instanceof Class) { - cz = (Class) f; - break; - } - } - clazz = cz; - if (cz == null) throw new ConvertException("not support the type (" + type + ")"); - } else if (type instanceof Class) { - clazz = (Class) type; - } else { - throw new ConvertException("not support the type (" + type + ")"); - } - decoder = findDecoder(clazz); - if (decoder != null) return decoder; - return createDecoder(type, clazz); - } - - public final Decodeable createDecoder(final Type type) { - Class clazz; - if (type instanceof ParameterizedType) { - final ParameterizedType pts = (ParameterizedType) type; - clazz = (Class) (pts).getRawType(); - } else if (type instanceof Class) { - clazz = (Class) type; - } else { - throw new ConvertException("not support the type (" + type + ")"); - } - return createDecoder(type, clazz); - } - - private Decodeable createDecoder(final Type type, final Class clazz) { - Decodeable decoder = null; - ObjectDecoder od = null; - if (clazz.isEnum()) { - decoder = new EnumSimpledCoder(clazz); - } else if (clazz.isArray()) { - decoder = new ArrayDecoder(this, type); - } else if (Collection.class.isAssignableFrom(clazz)) { - decoder = new CollectionDecoder(this, type); - } else if (Map.class.isAssignableFrom(clazz)) { - decoder = new MapDecoder(this, type); - } else if (clazz == Object.class) { - od = new ObjectDecoder(type); - decoder = od; - } else if (!clazz.getName().startsWith("java.")) { - SimpledCoder simpleCoder = null; - for (final Method method : clazz.getDeclaredMethods()) { - if (!Modifier.isStatic(method.getModifiers())) continue; - if (method.getParameterTypes().length != 0) continue; - if (method.getReturnType() != SimpledCoder.class) continue; - try { - method.setAccessible(true); - simpleCoder = (SimpledCoder) method.invoke(null); - break; - } catch (Exception e) { - } - } - if (simpleCoder == null) { - od = new ObjectDecoder(type); - decoder = od; - } else { - decoder = simpleCoder; - } - } - if (decoder == null) throw new ConvertException("not support the type (" + type + ")"); - register(type, decoder); - if (od != null) od.init(this); - return decoder; - } - - public final Encodeable loadEncoder(final Type type) { - Encodeable encoder = findEncoder(type); - if (encoder != null) return encoder; - if (type instanceof GenericArrayType) return new ArrayEncoder(this, type); - Class clazz; - if (type instanceof ParameterizedType) { - final ParameterizedType pts = (ParameterizedType) type; - clazz = (Class) (pts).getRawType(); - } else if (type instanceof TypeVariable) { - TypeVariable tv = (TypeVariable) type; - Type t = Object.class; - if (tv.getBounds().length == 1) { - t = tv.getBounds()[0]; - } - if (!(t instanceof Class)) t = Object.class; - clazz = (Class) t; - } else if (type instanceof Class) { - clazz = (Class) type; - } else { - throw new ConvertException("not support the type (" + type + ")"); - } - encoder = findEncoder(clazz); - if (encoder != null) return encoder; - return createEncoder(type, clazz); - } - - public final Encodeable createEncoder(final Type type) { - Class clazz; - if (type instanceof ParameterizedType) { - final ParameterizedType pts = (ParameterizedType) type; - clazz = (Class) (pts).getRawType(); - } else if (type instanceof Class) { - clazz = (Class) type; - } else { - throw new ConvertException("not support the type (" + type + ")"); - } - return createEncoder(type, clazz); - } - - private Encodeable createEncoder(final Type type, final Class clazz) { - Encodeable encoder = null; - ObjectEncoder oe = null; - if (clazz.isEnum()) { - encoder = new EnumSimpledCoder(clazz); - } else if (clazz.isArray()) { - encoder = new ArrayEncoder(this, type); - } else if (Collection.class.isAssignableFrom(clazz)) { - encoder = new CollectionEncoder(this, type); - } else if (Map.class.isAssignableFrom(clazz)) { - encoder = new MapEncoder(this, type); - } else if (clazz == Object.class) { - return (Encodeable) this.anyEncoder; - } else if (!clazz.getName().startsWith("java.")) { - SimpledCoder simpleCoder = null; - for (final Method method : clazz.getDeclaredMethods()) { - if (!Modifier.isStatic(method.getModifiers())) continue; - if (method.getParameterTypes().length != 0) continue; - if (method.getReturnType() != SimpledCoder.class) continue; - try { - method.setAccessible(true); - simpleCoder = (SimpledCoder) method.invoke(null); - break; - } catch (Exception e) { - } - } - if (simpleCoder == null) { - oe = new ObjectEncoder(type); - encoder = oe; - } else { - encoder = simpleCoder; - } - } - if (encoder == null) throw new ConvertException("not support the type (" + type + ")"); - register(type, encoder); - if (oe != null) oe.init(this); - return encoder; - - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/MapDecoder.java b/android-jdk6-redkale/src/org/redkale/convert/MapDecoder.java deleted file mode 100644 index addecb82d..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/MapDecoder.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import org.redkale.util.Creator; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.Map; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -@SuppressWarnings("unchecked") -public final class MapDecoder implements Decodeable> { - - private final Type type; - - private final Type keyType; - - private final Type valueType; - - protected Creator> creator; - - private final Decodeable keyDecoder; - - private final Decodeable valueDecoder; - - public MapDecoder(final Factory factory, final Type type) { - this.type = type; - if (type instanceof ParameterizedType) { - final ParameterizedType pt = (ParameterizedType) type; - this.keyType = pt.getActualTypeArguments()[0]; - this.valueType = pt.getActualTypeArguments()[1]; - this.creator = factory.loadCreator((Class) pt.getRawType()); - factory.register(type, this); - this.keyDecoder = factory.loadDecoder(this.keyType); - this.valueDecoder = factory.loadDecoder(this.valueType); - } else { - throw new ConvertException("mapdecoder not support the type (" + type + ")"); - } - } - - @Override - public Map convertFrom(Reader in) { - final int len = in.readMapB(); - if (len == Reader.SIGN_NULL) return null; - final Map result = this.creator.create(); - if (len == Reader.SIGN_NOLENGTH) { - while (in.hasNext()) { - K key = keyDecoder.convertFrom(in); - in.skipBlank(); - V value = valueDecoder.convertFrom(in); - result.put(key, value); - } - } else { - for (int i = 0; i < len; i++) { - K key = keyDecoder.convertFrom(in); - in.skipBlank(); - V value = valueDecoder.convertFrom(in); - result.put(key, value); - } - } - in.readMapE(); - return result; - } - - @Override - public Type getType() { - return this.type; - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/MapEncoder.java b/android-jdk6-redkale/src/org/redkale/convert/MapEncoder.java deleted file mode 100644 index 544100d71..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/MapEncoder.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.Map; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -@SuppressWarnings("unchecked") -public final class MapEncoder implements Encodeable> { - - private final Type type; - - private final Encodeable keyencoder; - - private final Encodeable valencoder; - - public MapEncoder(final Factory factory, final Type type) { - this.type = type; - if (type instanceof ParameterizedType) { - final Type[] pt = ((ParameterizedType) type).getActualTypeArguments(); - this.keyencoder = factory.loadEncoder(pt[0]); - this.valencoder = factory.loadEncoder(pt[1]); - } else { - this.keyencoder = factory.getAnyEncoder(); - this.valencoder = factory.getAnyEncoder(); - } - } - - @Override - public void convertTo(Writer out, Map value) { - final Map values = value; - if (values == null) { - out.writeNull(); - return; - } - out.writeMapB(values.size()); - boolean first = true; - for (Map.Entry en : values.entrySet()) { - if (!first) out.writeArrayMark(); - this.keyencoder.convertTo(out, en.getKey()); - out.writeMapMark(); - this.valencoder.convertTo(out, en.getValue()); - if (first) first = false; - } - out.writeMapE(); - } - - @Override - public Type getType() { - return type; - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ObjectDecoder.java b/android-jdk6-redkale/src/org/redkale/convert/ObjectDecoder.java deleted file mode 100644 index 94c5269aa..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ObjectDecoder.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import org.redkale.util.Creator; -import java.lang.reflect.*; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; -import org.redkale.util.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -@SuppressWarnings("unchecked") -public final class ObjectDecoder implements Decodeable { - - protected final Type type; - - protected final Class typeClass; - - protected Creator creator; - - protected DeMember[] creatorConstructorMembers; - - protected DeMember[] members; - - protected Factory factory; - - private boolean inited = false; - - private final Object lock = new Object(); - - protected ObjectDecoder(Type type) { - this.type = ((type instanceof Class) && ((Class) type).isInterface()) ? Object.class : type; - if (type instanceof ParameterizedType) { - final ParameterizedType pt = (ParameterizedType) type; - this.typeClass = (Class) pt.getRawType(); - } else { - this.typeClass = (Class) type; - } - this.members = new DeMember[0]; - } - - public void init(final Factory factory) { - this.factory = factory; - try { - if (type == Object.class) return; - - Class clazz = null; - if (type instanceof ParameterizedType) { - final ParameterizedType pts = (ParameterizedType) type; - clazz = (Class) (pts).getRawType(); - } else if (!(type instanceof Class)) { - throw new ConvertException("[" + type + "] is no a class"); - } else { - clazz = (Class) type; - } - this.creator = factory.loadCreator(clazz); - - final Set list = new HashSet(); - final String[] cps = ObjectEncoder.findConstructorProperties(this.creator); - try { - ConvertColumnEntry ref; - for (final Field field : clazz.getFields()) { - if (Modifier.isStatic(field.getModifiers())) continue; - ref = factory.findRef(field); - if (ref != null && ref.ignore()) continue; - Type t = ObjectEncoder.createClassType(field.getGenericType(), this.type); - list.add(new DeMember(ObjectEncoder.createAttribute(factory, clazz, field, null, null), factory.loadDecoder(t))); - } - final boolean reversible = factory.isReversible(); - for (final Method method : clazz.getMethods()) { - if (Modifier.isStatic(method.getModifiers())) continue; - if (Modifier.isAbstract(method.getModifiers())) continue; - if (method.isSynthetic()) continue; - if (method.getName().length() < 4) continue; - if (!method.getName().startsWith("set")) continue; - if (method.getParameterTypes().length != 1) continue; - if (method.getReturnType() != void.class) continue; - if (reversible && (cps == null || !ObjectEncoder.contains(cps, ObjectEncoder.readGetSetFieldName(method)))) { - boolean is = method.getParameterTypes()[0] == boolean.class || method.getParameterTypes()[0] == Boolean.class; - try { - clazz.getMethod(method.getName().replaceFirst("set", is ? "is" : "get")); - } catch (Exception e) { - continue; - } - } - ref = factory.findRef(method); - if (ref != null && ref.ignore()) continue; - Type t = ObjectEncoder.createClassType(method.getGenericParameterTypes()[0], this.type); - list.add(new DeMember(ObjectEncoder.createAttribute(factory, clazz, null, null, method), factory.loadDecoder(t))); - } - if (cps != null) { //可能存在某些构造函数中的字段名不存在setter方法 - for (final String constructorField : cps) { - boolean flag = false; - for (DeMember m : list) { - if (m.attribute.field().equals(constructorField)) { - flag = true; - break; - } - } - if (flag) continue; - //不存在setter方法 - try { - Field f = clazz.getDeclaredField(constructorField); - Type t = ObjectEncoder.createClassType(f.getGenericType(), this.type); - list.add(new DeMember(ObjectEncoder.createAttribute(factory, clazz, f, null, null), factory.loadDecoder(t))); - } catch (NoSuchFieldException nsfe) { //不存在field, 可能存在getter方法 - char[] fs = constructorField.toCharArray(); - fs[0] = Character.toUpperCase(fs[0]); - String mn = new String(fs); - Method getter; - try { - getter = clazz.getMethod("get" + mn); - } catch (NoSuchMethodException ex) { - getter = clazz.getMethod("is" + mn); - } - Type t = ObjectEncoder.createClassType(getter.getGenericParameterTypes()[0], this.type); - list.add(new DeMember(ObjectEncoder.createAttribute(factory, clazz, null, getter, null), factory.loadDecoder(t))); - } - } - } - this.members = list.toArray(new DeMember[list.size()]); - Arrays.sort(this.members); - - if (cps != null) { - final String[] fields = cps; - final DeMember[] ms = new DeMember[fields.length]; - for (int i = 0; i < fields.length; i++) { - for (DeMember m : this.members) { - if (m.attribute.field().equals(fields[i])) { - ms[i] = m; - break; - } - } - } - this.creatorConstructorMembers = ms; - } - } catch (Exception ex) { - throw new ConvertException(ex); - } - } finally { - inited = true; - synchronized (lock) { - lock.notifyAll(); - } - } - } - - /** - * 对象格式: [0x1][short字段个数][字段名][字段值]...[0x2] - * - * @param in - * @return - */ - @Override - public final T convertFrom(final R in) { - final String clazz = in.readClassName(); - if (clazz != null && !clazz.isEmpty()) return (T) factory.loadDecoder(factory.getEntity(clazz)).convertFrom(in); - if (in.readObjectB() == Reader.SIGN_NULL) return null; - if (!this.inited) { - synchronized (lock) { - try { - lock.wait(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - if (this.creatorConstructorMembers == null) { //空构造函数 - final T result = this.creator.create(); - final AtomicInteger index = new AtomicInteger(); - while (in.hasNext()) { - DeMember member = in.readField(index, members); - in.skipBlank(); - if (member == null) { - in.skipValue(); //跳过该属性的值 - } else { - member.read(in, result); - } - index.incrementAndGet(); - } - in.readObjectE(); - return result; - } else { //带参数的构造函数 - final DeMember[] fields = this.creatorConstructorMembers; - final Object[] constructorParams = new Object[fields.length]; - final Object[][] otherParams = new Object[this.members.length][2]; - final AtomicInteger index = new AtomicInteger(); - int oc = 0; - while (in.hasNext()) { - DeMember member = in.readField(index, members); - in.skipBlank(); - if (member == null) { - in.skipValue(); //跳过该属性的值 - } else { - Object val = member.read(in); - boolean flag = true; - for (int i = 0; i < fields.length; i++) { - if (member == fields[i]) { - constructorParams[i] = val; - flag = false; - break; - } - } - if (flag) otherParams[oc++] = new Object[]{member.attribute, val}; - } - index.incrementAndGet(); - } - in.readObjectE(); - final T result = this.creator.create(constructorParams); - for (int i = 0; i < oc; i++) { - ((Attribute) otherParams[i][0]).set(result, otherParams[i][1]); - } - return result; - } - } - - @Override - public final Type getType() { - return this.type; - } - - @Override - public String toString() { - return "ObjectDecoder{" + "type=" + type + ", members=" + Arrays.toString(members) + '}'; - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ObjectEncoder.java b/android-jdk6-redkale/src/org/redkale/convert/ObjectEncoder.java deleted file mode 100644 index 77134001b..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ObjectEncoder.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import org.redkale.util.Attribute; -import java.lang.reflect.*; -import java.util.*; -import org.redkale.util.*; -import org.redkale.util.Attribute.Attributes; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -@SuppressWarnings("unchecked") -public final class ObjectEncoder implements Encodeable { - - static final Type[] TYPEZERO = new Type[0]; - - protected final Type type; - - protected final Class typeClass; - - protected EnMember[] members; - - protected Factory factory; - - private boolean inited = false; - - private final Object lock = new Object(); - - protected ObjectEncoder(Type type) { - this.type = type; - if (type instanceof ParameterizedType) { - final ParameterizedType pt = (ParameterizedType) type; - this.typeClass = (Class) pt.getRawType(); - } else { - this.typeClass = (Class) type; - } - this.members = new EnMember[0]; - } - - public void init(final Factory factory) { - this.factory = factory; - try { - if (type == Object.class) return; - //if (!(type instanceof Class)) throw new ConvertException("[" + type + "] is no a class"); - final Class clazz = this.typeClass; - final Set list = new HashSet(); - final String[] cps = ObjectEncoder.findConstructorProperties(factory.loadCreator(this.typeClass)); - try { - ConvertColumnEntry ref; - for (final Field field : clazz.getFields()) { - if (Modifier.isStatic(field.getModifiers())) continue; - ref = factory.findRef(field); - if (ref != null && ref.ignore()) continue; - Type t = createClassType(field.getGenericType(), this.type); - list.add(new EnMember(createAttribute(factory, clazz, field, null, null), factory.loadEncoder(t))); - } - final boolean reversible = factory.isReversible(); - for (final Method method : clazz.getMethods()) { - if (Modifier.isStatic(method.getModifiers())) continue; - if (Modifier.isAbstract(method.getModifiers())) continue; - if (method.isSynthetic()) continue; - if (method.getName().length() < 3) continue; - if (method.getName().equals("getClass")) continue; - if (!method.getName().startsWith("is") && !method.getName().startsWith("get")) continue; - if (method.getParameterTypes().length != 0) continue; - if (method.getReturnType() == void.class) continue; - if (reversible && (cps == null || !contains(cps, readGetSetFieldName(method)))) { - boolean is = method.getName().startsWith("is"); - try { - clazz.getMethod(method.getName().replaceFirst(is ? "is" : "get", "set"), method.getReturnType()); - } catch (Exception e) { - continue; - } - } - ref = factory.findRef(method); - if (ref != null && ref.ignore()) continue; - Type t = createClassType(method.getGenericReturnType(), this.type); - list.add(new EnMember(createAttribute(factory, clazz, null, method, null), factory.loadEncoder(t))); - } - this.members = list.toArray(new EnMember[list.size()]); - Arrays.sort(this.members); - - } catch (Exception ex) { - throw new ConvertException(ex); - } - } finally { - inited = true; - synchronized (lock) { - lock.notifyAll(); - } - } - } - - @Override - public final void convertTo(W out, T value) { - if (value == null) { - out.wirteClassName(null); - out.writeNull(); - return; - } - if (!this.inited) { - synchronized (lock) { - try { - lock.wait(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - if (value != null && value.getClass() != this.typeClass) { - final Class clz = value.getClass(); - out.wirteClassName(factory.getEntity(clz)); - factory.loadEncoder(clz).convertTo(out, value); - return; - } - out.writeObjectB(members.length, value); - boolean comma = false; - for (EnMember member : members) { - comma = member.write(out, comma, value); - } - out.writeObjectE(value); - } - - @Override - public final Type getType() { - return this.type; - } - - @Override - public String toString() { - return "ObjectEncoder{" + "type=" + type + ", members=" + Arrays.toString(members) + '}'; - } - - static Type createClassType(final Type type, final Type declaringType) { - if (TypeToken.isClassType(type)) return type; - //存在通配符则declaringType 必须是 ParameterizedType - if (!(declaringType instanceof ParameterizedType)) return Object.class; - if (type instanceof ParameterizedType) { // e.g. Map - final ParameterizedType pt = (ParameterizedType) type; - final Type[] paramTypes = pt.getActualTypeArguments(); - for (int i = 0; i < paramTypes.length; i++) { - paramTypes[i] = createClassType(paramTypes[i], declaringType); - } - return TypeToken.createParameterizedType(pt.getOwnerType(), pt.getRawType(), paramTypes); - } - - final ParameterizedType declaringPType = (ParameterizedType) declaringType; - final Type[] virTypes = ((Class) declaringPType.getRawType()).getTypeParameters(); - final Type[] desTypes = declaringPType.getActualTypeArguments(); - if (type instanceof WildcardType) { // e.g. - final WildcardType wt = (WildcardType) type; - for (Type f : wt.getUpperBounds()) { - for (int i = 0; i < virTypes.length; i++) { - if (virTypes[i].equals(f)) return desTypes.length <= i ? Object.class : desTypes[i]; - } - } - } else if (type instanceof TypeVariable) { // e.g. - for (int i = 0; i < virTypes.length; i++) { - if (virTypes[i].equals(type)) return desTypes.length <= i ? Object.class : desTypes[i]; - } - } - return type; - } -// -// static Type makeGenericType(final Type type, final Type[] virGenericTypes, final Type[] realGenericTypes) { -// if (type instanceof Class) { //e.g. String -// return type; -// } else if (type instanceof ParameterizedType) { //e.g. Map -// final ParameterizedType pt = (ParameterizedType) type; -// Type[] paramTypes = pt.getActualTypeArguments(); -// final Type[] newTypes = new Type[paramTypes.length]; -// int count = 0; -// for (int i = 0; i < newTypes.length; i++) { -// newTypes[i] = makeGenericType(paramTypes[i], virGenericTypes, realGenericTypes); -// if (paramTypes[i] == newTypes[i]) count++; -// } -// if (count == paramTypes.length) return pt; -// return new ParameterizedType() { -// -// @Override -// public Type[] getActualTypeArguments() { -// return newTypes; -// } -// -// @Override -// public Type getRawType() { -// return pt.getRawType(); -// } -// -// @Override -// public Type getOwnerType() { -// return pt.getOwnerType(); -// } -// -// }; -// } -// if (realGenericTypes == null) return type; -// if (type instanceof WildcardType) { // e.g. -// final WildcardType wt = (WildcardType) type; -// for (Type f : wt.getUpperBounds()) { -// for (int i = 0; i < virGenericTypes.length; i++) { -// if (virGenericTypes[i] == f) return realGenericTypes.length == 0 ? Object.class : realGenericTypes[i]; -// } -// } -// } else if (type instanceof TypeVariable) { // e.g. -// for (int i = 0; i < virGenericTypes.length; i++) { -// if (virGenericTypes[i] == type) return i >= realGenericTypes.length ? Object.class : realGenericTypes[i]; -// } -// } -// return type; -// } - - static boolean contains(String[] values, String value) { - for (String str : values) { - if (str.equals(value)) return true; - } - return false; - } - - static String readGetSetFieldName(Method method) { - if (method == null) return null; - String fname = method.getName(); - if (!fname.startsWith("is") && !fname.startsWith("get") && !fname.startsWith("set")) return fname; - fname = fname.substring(fname.startsWith("is") ? 2 : 3); - if (fname.length() > 1 && !(fname.charAt(1) >= 'A' && fname.charAt(1) <= 'Z')) { - fname = Character.toLowerCase(fname.charAt(0)) + fname.substring(1); - } else if (fname.length() == 1) { - fname = "" + Character.toLowerCase(fname.charAt(0)); - } - return fname; - } - - static String[] findConstructorProperties(Creator creator) { - try { - Creator.ConstructorParameters cps = creator.getClass().getMethod("create", Object[].class).getAnnotation(Creator.ConstructorParameters.class); - return cps == null ? null : cps.value(); - } catch (Exception e) { - return null; - } - } - - static Attribute createAttribute(final Factory factory, Class clazz, final Field field, final Method getter, final Method setter) { - String fieldalias = null; - if (field != null) { // public field - ConvertColumnEntry ref = factory.findRef(field); - fieldalias = ref == null || ref.name().isEmpty() ? field.getName() : ref.name(); - } else if (getter != null) { - ConvertColumnEntry ref = factory.findRef(getter); - String mfieldname = readGetSetFieldName(getter); - if (ref == null) { - try { - ref = factory.findRef(clazz.getDeclaredField(mfieldname)); - } catch (Exception e) { - } - } - fieldalias = ref == null || ref.name().isEmpty() ? mfieldname : ref.name(); - } else { // setter != null - ConvertColumnEntry ref = factory.findRef(setter); - String mfieldname = readGetSetFieldName(setter); - if (ref == null) { - try { - ref = factory.findRef(clazz.getDeclaredField(mfieldname)); - } catch (Exception e) { - } - } - fieldalias = ref == null || ref.name().isEmpty() ? mfieldname : ref.name(); - } - return Attributes.create(clazz, fieldalias, field, getter, setter); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/Reader.java b/android-jdk6-redkale/src/org/redkale/convert/Reader.java deleted file mode 100644 index fb6114d5d..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/Reader.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import java.util.concurrent.atomic.AtomicInteger; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public interface Reader { - - public static final short SIGN_NULL = -1; - - public static final short SIGN_NOLENGTH = -2; - - /** - * 是否还存在下个元素或字段 - * - * @return - */ - public boolean hasNext(); - - /** - * 跳过值(不包含值前面的字段) - */ - public void skipValue(); - - /** - * /跳过字段与值之间的多余内容, json就是跳过:符, map跳过: - */ - public void skipBlank(); - - /** - * 读取对象的开头 返回字段数 - * - * @return - */ - public int readObjectB(); - - /** - * 读取对象的尾端 - * - */ - public void readObjectE(); - - /** - * 读取数组的开头并返回数组的长度 - * - * @return - */ - public int readArrayB(); - - /** - * 读取数组的尾端 - * - */ - public void readArrayE(); - - /** - * 读取map的开头并返回map的size - * - * @return - */ - public int readMapB(); - - /** - * 读取数组的尾端 - * - */ - public void readMapE(); - - /** - * 根据字段读取字段对应的DeMember - * - * @param index - * @param members - * @return - */ - public DeMember readField(final AtomicInteger index, final DeMember[] members); - - public boolean readBoolean(); - - public byte readByte(); - - public char readChar(); - - public short readShort(); - - public int readInt(); - - public long readLong(); - - public float readFloat(); - - public double readDouble(); - - /** - * 读取无转义字符长度不超过255的字符串, 例如枚举值、字段名、类名字符串等 - * - * @return - */ - public String readSmallString(); - - public String readClassName(); - - public String readString(); - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/SimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/SimpledCoder.java deleted file mode 100644 index 645befaf9..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/SimpledCoder.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - * @param - */ -public abstract class SimpledCoder implements Decodeable, Encodeable { - - private Type type; - - @Override - public abstract void convertTo(final W out, final T value); - - @Override - public abstract T convertFrom(final R in); - - @Override - @SuppressWarnings("unchecked") - public Class getType() { - if (type == null) { - Type[] ts = ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments(); - type = ts[ts.length - 1]; - } - return (Class) type; - } - - @Override - public String toString() { - return this.getClass().getSimpleName(); - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/Writer.java b/android-jdk6-redkale/src/org/redkale/convert/Writer.java deleted file mode 100644 index e295d60a1..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/Writer.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert; - -import org.redkale.util.Attribute; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public interface Writer { - - /** - * 当tiny=true时, 字符串为空、boolean为false的字段值都会被跳过, 不会输出。 - *

- * @return - */ - public boolean isTiny(); - - /** - * 输出null值 - */ - public void writeNull(); - - /** - * - * @param clazz - */ - public void wirteClassName(String clazz); - - /** - * 输出一个对象前的操作 - * - * @param fieldCount 字段个数 - * - * @param obj - */ - public void writeObjectB(int fieldCount, Object obj); - - /** - * 输出一个对象后的操作 - * - * @param obj - */ - public void writeObjectE(Object obj); - - /** - * 输出一个数组前的操作 - * - * @param size 数组长度 - */ - public void writeArrayB(int size); - - /** - * 输出数组元素间的间隔符 - * - */ - public void writeArrayMark(); - - /** - * 输出一个数组后的操作 - * - */ - public void writeArrayE(); - - /** - * 输出一个Map前的操作 - * - * @param size map大小 - */ - public void writeMapB(int size); - - /** - * 输出一个Map中key与value间的间隔符 - * - */ - public void writeMapMark(); - - /** - * 输出一个Map后的操作 - * - */ - public void writeMapE(); - - /** - * 输出一个字段 - * - * @param comma 是否非第一个字段 - * @param attribute - */ - public void writeField(boolean comma, Attribute attribute); - - public void writeBoolean(boolean value); - - public void writeByte(byte value); - - public void writeChar(char value); - - public void writeShort(short value); - - public void writeInt(int value); - - public void writeLong(long value); - - public void writeFloat(float value); - - public void writeDouble(double value); - - /** - * 写入无转义字符长度不超过255的字符串, 例如枚举值、字段名、类名字符串等 * - * - * @param value - */ - public void writeSmallString(String value); - - public void writeString(String value); -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/bson/BsonByteBufferWriter.java b/android-jdk6-redkale/src/org/redkale/convert/bson/BsonByteBufferWriter.java deleted file mode 100644 index 0cc0b5c04..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/bson/BsonByteBufferWriter.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.bson; - -import java.nio.*; -import java.util.function.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public final class BsonByteBufferWriter extends BsonWriter { - - private final Supplier supplier; - - private ByteBuffer[] buffers; - - private int index; - - protected BsonByteBufferWriter(Supplier supplier) { - super((byte[]) null); - this.supplier = supplier; - } - - @Override - public ByteBuffer[] toBuffers() { - if (buffers == null) return new ByteBuffer[0]; - for (int i = index; i < this.buffers.length; i++) { - ByteBuffer buf = this.buffers[i]; - if (buf.position() != 0) buf.flip(); - } - return this.buffers; - } - - @Override - public byte[] toArray() { - if (buffers == null) return new byte[0]; - int pos = 0; - byte[] bytes = new byte[this.count]; - for (ByteBuffer buf : toBuffers()) { - int r = buf.remaining(); - buf.get(bytes, pos, r); - buf.flip(); - pos += r; - } - return bytes; - } - - @Override - public String toString() { - return this.getClass().getSimpleName() + "[count=" + this.count + "]"; - } - - @Override - public BsonByteBufferWriter setTiny(boolean tiny) { - this.tiny = tiny; - return this; - } - - @Override - protected int expand(final int byteLength) { - if (this.buffers == null) { - this.index = 0; - this.buffers = new ByteBuffer[]{supplier.get()}; - } - ByteBuffer buffer = this.buffers[index]; - if (!buffer.hasRemaining()) { - buffer.flip(); - buffer = supplier.get(); - ByteBuffer[] bufs = new ByteBuffer[this.buffers.length + 1]; - System.arraycopy(this.buffers, 0, bufs, 0, this.buffers.length); - bufs[this.buffers.length] = buffer; - this.buffers = bufs; - this.index++; - } - int len = buffer.remaining(); - int size = 0; - while (len < byteLength) { - buffer = supplier.get(); - ByteBuffer[] bufs = new ByteBuffer[this.buffers.length + 1]; - System.arraycopy(this.buffers, 0, bufs, 0, this.buffers.length); - bufs[this.buffers.length] = buffer; - this.buffers = bufs; - len += buffer.remaining(); - size++; - } - return size; - } - - @Override - public void writeTo(final byte[] chs, final int start, final int len) { - if (expand(len) == 0) { - this.buffers[index].put(chs, start, len); - } else { - ByteBuffer buffer = this.buffers[index]; - final int end = start + len; - int remain = len; //还剩多少没有写 - while (remain > 0) { - final int br = buffer.remaining(); - if (remain > br) { //一个buffer写不完 - buffer.put(chs, end - remain, br); - buffer = nextByteBuffer(); - remain -= br; - } else { - buffer.put(chs, end - remain, remain); - remain = 0; - } - } - } - this.count += len; - } - - private ByteBuffer nextByteBuffer() { - this.buffers[this.index].flip(); - return this.buffers[++this.index]; - } - - @Override - public void writeTo(final byte ch) { - expand(1); - this.buffers[index].put(ch); - count++; - } - - @Override - protected boolean recycle() { - this.index = 0; - this.buffers = null; - return false; - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/bson/BsonConvert.java b/android-jdk6-redkale/src/org/redkale/convert/bson/BsonConvert.java deleted file mode 100644 index f60a23b33..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/bson/BsonConvert.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.bson; - -import java.lang.reflect.*; -import java.nio.*; -import java.util.function.*; -import org.redkale.convert.*; -import org.redkale.util.*; - -/** - * BSON协议格式: - * 1). 基本数据类型: 直接转换成byte[] - * 2). SmallString(无特殊字符且长度小于256的字符串): length(1 byte) + byte[](utf8); 通常用于类名、字段名、枚举。 - * 3). String: length(4 bytes) + byte[](utf8); - * 4). 数组: length(4 bytes) + byte[]... - * 5). Object: - * 1. realclass (SmallString) (如果指定格式化的class与实体对象的class不一致才会有该值) - * 2. 空字符串(SmallString) - * 3. SIGN_OBJECTB 标记位,值固定为0xBB (short) - * 4. 循环字段值: - * 4.1 SIGN_HASNEXT 标记位,值固定为1 (byte) - * 4.2 字段类型; 1-9为基本类型&字符串; 101-109为基本类型&字符串的数组; 127为Object - * 4.3 字段名 (SmallString) - * 4.4 字段的值Object - * 5. SIGN_NONEXT 标记位,值固定为0 (byte) - * 6. SIGN_OBJECTE 标记位,值固定为0xEE (short) - * - * @see http://www.redkale.org - * @author zhangjx - */ -public final class BsonConvert extends Convert { - - private static final ObjectPool readerPool = BsonReader.createPool(Integer.getInteger("convert.bson.pool.size", 16)); - - private static final ObjectPool writerPool = BsonWriter.createPool(Integer.getInteger("convert.bson.pool.size", 16)); - - private final boolean tiny; - - protected BsonConvert(Factory factory, boolean tiny) { - super(factory); - this.tiny = tiny; - } - - public BsonByteBufferWriter pollBsonWriter(final Supplier supplier) { - return new BsonByteBufferWriter(supplier).setTiny(tiny); - } - - public BsonWriter pollBsonWriter() { - return writerPool.get().setTiny(tiny); - } - - public void offerBsonWriter(BsonWriter out) { - if (out != null) writerPool.offer(out); - } - - public BsonReader pollBsonReader() { - return readerPool.get(); - } - - public void offerBsonReader(BsonReader in) { - if (in != null) readerPool.offer(in); - } - - public T convertFrom(final Type type, final byte[] bytes) { - if (bytes == null) return null; - return convertFrom(type, bytes, 0, bytes.length); - } - - public T convertFrom(final Type type, final byte[] bytes, int start, int len) { - if (type == null) return null; - final BsonReader in = readerPool.get(); - in.setBytes(bytes, start, len); - @SuppressWarnings("unchecked") - T rs = (T) factory.loadDecoder(type).convertFrom(in); - readerPool.offer(in); - return rs; - } - - public T convertFrom(final BsonReader in, final Type type) { - if (type == null) return null; - @SuppressWarnings("unchecked") - T rs = (T) factory.loadDecoder(type).convertFrom(in); - return rs; - } - - public byte[] convertTo(final Type type, Object value) { - if (type == null) return null; - final BsonWriter out = writerPool.get().setTiny(tiny); - factory.loadEncoder(type).convertTo(out, value); - byte[] result = out.toArray(); - writerPool.offer(out); - return result; - } - - public void convertTo(final BsonWriter out, final Type type, Object value) { - if (type == null) return; - factory.loadEncoder(type).convertTo(out, value); - } - - public ByteBuffer[] convertTo(final Supplier supplier, final Type type, Object value) { - if (supplier == null || type == null) return null; - BsonByteBufferWriter out = new BsonByteBufferWriter(supplier); - if (value == null) { - out.writeNull(); - } else { - factory.loadEncoder(type).convertTo(out, value); - } - return out.toBuffers(); - } - - public ByteBuffer[] convertTo(final Supplier supplier, Object value) { - if (supplier == null) return null; - BsonByteBufferWriter out = new BsonByteBufferWriter(supplier); - if (value == null) { - out.writeNull(); - } else { - factory.loadEncoder(value.getClass()).convertTo(out, value); - } - return out.toBuffers(); - } - - public void convertTo(final BsonWriter out, Object value) { - if (value == null) { - out.writeNull(); - } else { - factory.loadEncoder(value.getClass()).convertTo(out, value); - } - } - - public byte[] convertTo(Object value) { - if (value == null) { - final BsonWriter out = writerPool.get().setTiny(tiny); - out.writeNull(); - byte[] result = out.toArray(); - writerPool.offer(out); - return result; - } - return convertTo(value.getClass(), value); - } - - public BsonWriter convertToWriter(final Type type, Object value) { - if (type == null) return null; - final BsonWriter out = writerPool.get().setTiny(tiny); - factory.loadEncoder(type).convertTo(out, value); - return out; - } - - public BsonWriter convertToWriter(Object value) { - if (value == null) return null; - return convertToWriter(value.getClass(), value); - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/bson/BsonFactory.java b/android-jdk6-redkale/src/org/redkale/convert/bson/BsonFactory.java deleted file mode 100644 index ecf3a15ee..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/bson/BsonFactory.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.bson; - -import java.io.Serializable; -import org.redkale.convert.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public final class BsonFactory extends Factory { - - private static final BsonFactory instance = new BsonFactory(null, Boolean.getBoolean("convert.bson.tiny")); - - static final Decodeable objectDecoder = instance.loadDecoder(Object.class); - - static final Encodeable objectEncoder = instance.loadEncoder(Object.class); - - static { - instance.register(Serializable.class, objectDecoder); - instance.register(Serializable.class, objectEncoder); - } - - private BsonFactory(BsonFactory parent, boolean tiny) { - super(parent, tiny); - } - - public static BsonFactory root() { - return instance; - } - - @Override - public final BsonConvert getConvert() { - if (convert == null) convert = new BsonConvert(this, tiny); - return (BsonConvert) convert; - } - - @Override - public BsonFactory createChild() { - return new BsonFactory(this, this.tiny); - } - - @Override - public BsonFactory createChild(boolean tiny) { - return new BsonFactory(this, tiny); - } - - @Override - public ConvertType getConvertType() { - return ConvertType.BSON; - } - - @Override - public boolean isReversible() { - return true; - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/bson/BsonReader.java b/android-jdk6-redkale/src/org/redkale/convert/bson/BsonReader.java deleted file mode 100644 index 57fda8155..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/bson/BsonReader.java +++ /dev/null @@ -1,324 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.bson; - -import java.util.concurrent.atomic.*; -import java.util.function.*; -import org.redkale.convert.*; -import static org.redkale.convert.Reader.SIGN_NULL; -import org.redkale.convert.ext.*; -import org.redkale.util.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public final class BsonReader implements Reader { - - public static final short SIGN_OBJECTB = (short) 0xBB; - - public static final short SIGN_OBJECTE = (short) 0xEE; - - public static final byte SIGN_HASNEXT = 1; - - public static final byte SIGN_NONEXT = 0; - - public static final byte VERBOSE_NO = 1; - - public static final byte VERBOSE_YES = 2; - - private int position = -1; - - private byte typeval; //字段的类型值 对应 BsonWriter.writeField - - private byte[] content; - - public BsonReader() { - } - - public static ObjectPool createPool(int max) { - return new ObjectPool(max, new Creator() { - - @Override - public BsonReader create(Object... params) { - return new BsonReader(); - } - }, null, new Predicate() { - - @Override - public boolean test(BsonReader t) { - return t.recycle(); - } - }); - } - - public BsonReader(byte[] bytes) { - setBytes(bytes, 0, bytes.length); - } - - public BsonReader(byte[] bytes, int start, int len) { - setBytes(bytes, start, len); - } - - public final void setBytes(byte[] bytes) { - if (bytes == null) { - this.position = 0; - } else { - setBytes(bytes, 0, bytes.length); - } - } - - public final void setBytes(byte[] bytes, int start, int len) { - if (bytes == null) { - this.position = 0; - } else { - this.content = bytes; - this.position = start - 1; - //this.limit = start + len - 1; - } - } - - protected boolean recycle() { - this.position = -1; - this.typeval = 0; - //this.limit = -1; - this.content = null; - return true; - } - - public void close() { - this.recycle(); - } - - /** - * 跳过属性的值 - */ - @Override - public final void skipValue() { - if (typeval == 0) return; - final byte val = this.typeval; - this.typeval = 0; - switch (val) { - case 1: readBoolean(); - break; - case 2: readByte(); - break; - case 3: readShort(); - break; - case 4: readChar(); - break; - case 5: readInt(); - break; - case 6: readLong(); - break; - case 7: readFloat(); - break; - case 8: readDouble(); - break; - case 9: readString(); - break; - case 101: - BoolArraySimpledCoder.instance.convertFrom(this); - break; - case 102: - ByteArraySimpledCoder.instance.convertFrom(this); - break; - case 103: - ShortArraySimpledCoder.instance.convertFrom(this); - break; - case 104: - CharArraySimpledCoder.instance.convertFrom(this); - break; - case 105: - IntArraySimpledCoder.instance.convertFrom(this); - break; - case 106: - LongArraySimpledCoder.instance.convertFrom(this); - break; - case 107: - FloatArraySimpledCoder.instance.convertFrom(this); - break; - case 108: - DoubleArraySimpledCoder.instance.convertFrom(this); - break; - case 109: - StringArraySimpledCoder.instance.convertFrom(this); - break; - case 127: - BsonFactory.objectDecoder.convertFrom(this); - break; - } - } - - /** - * 判断下一个非空白字节是否为{ - * - */ - @Override - public int readObjectB() { - short bt = readShort(); - if (bt == Reader.SIGN_NULL) return bt; - if (bt != SIGN_OBJECTB) { - throw new ConvertException("a bson object must begin with " + (SIGN_OBJECTB) - + " (position = " + position + ") but '" + this.content[this.position] + "'"); - } - return bt; - } - - @Override - public void readObjectE() { - if (readShort() != SIGN_OBJECTE) { - throw new ConvertException("a bson object must end with " + (SIGN_OBJECTE) - + " (position = " + position + ") but '" + this.content[this.position] + "'"); - } - } - - @Override - public int readMapB() { - return readArrayB(); - } - - @Override - public void readMapE() { - } - - /** - * 判断下一个非空白字节是否为[ - * - * @return - */ - @Override - public int readArrayB() { - short bt = readShort(); - if (bt == Reader.SIGN_NULL) return bt; - return (bt & 0xffff) << 16 | ((content[++this.position] & 0xff) << 8) | (content[++this.position] & 0xff); - } - - @Override - public void readArrayE() { - } - - /** - * 判断下一个非空白字节是否: - */ - @Override - public void skipBlank() { - } - - /** - * 判断对象是否存在下一个属性或者数组是否存在下一个元素 - * - * @return - */ - @Override - public boolean hasNext() { - byte b = readByte(); - if (b == SIGN_HASNEXT) return true; - if (b != SIGN_NONEXT) throw new ConvertException("hasNext option must be (" + (SIGN_HASNEXT) - + " or " + (SIGN_NONEXT) + ") but '" + b + "' at position(" + this.position + ")"); - return false; - } - - @Override - public DeMember readField(final AtomicInteger index, final DeMember[] members) { - final String exceptedfield = readSmallString(); - this.typeval = readByte(); - final int len = members.length; - int v = index.get(); - if (v >= len) { - v = 0; - index.set(0); - } - for (int k = v; k < len; k++) { - if (exceptedfield.equals(members[k].getAttribute().field())) { - index.set(k); - return members[k]; - } - } - for (int k = 0; k < v; k++) { - if (exceptedfield.equals(members[k].getAttribute().field())) { - index.set(k); - return members[k]; - } - } - return null; - } - - //------------------------------------------------------------ - @Override - public boolean readBoolean() { - return content[++this.position] == 1; - } - - @Override - public byte readByte() { - return content[++this.position]; - } - - @Override - public char readChar() { - return (char) ((0xff00 & (content[++this.position] << 8)) | (0xff & content[++this.position])); - } - - @Override - public short readShort() { - return (short) ((0xff00 & (content[++this.position] << 8)) | (0xff & content[++this.position])); - } - - @Override - public int readInt() { - return ((content[++this.position] & 0xff) << 24) | ((content[++this.position] & 0xff) << 16) - | ((content[++this.position] & 0xff) << 8) | (content[++this.position] & 0xff); - } - - @Override - public long readLong() { - return ((((long) content[++this.position] & 0xff) << 56) - | (((long) content[++this.position] & 0xff) << 48) - | (((long) content[++this.position] & 0xff) << 40) - | (((long) content[++this.position] & 0xff) << 32) - | (((long) content[++this.position] & 0xff) << 24) - | (((long) content[++this.position] & 0xff) << 16) - | (((long) content[++this.position] & 0xff) << 8) - | (((long) content[++this.position] & 0xff))); - } - - @Override - public float readFloat() { - return Float.intBitsToFloat(readInt()); - } - - @Override - public double readDouble() { - return Double.longBitsToDouble(readLong()); - } - - @Override - public String readClassName() { - return readSmallString(); - } - - @Override - public String readSmallString() { - int len = 0xff & readByte(); - if (len == 0) return ""; - String value = new String(content, ++this.position, len); - this.position += len - 1; - return value; - } - - @Override - public String readString() { - int len = readInt(); - if (len == SIGN_NULL) return null; - if (len == 0) return ""; - String value = new String(Utility.decodeUTF8(content, ++this.position, len)); - this.position += len - 1; - return value; - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/bson/BsonSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/bson/BsonSimpledCoder.java deleted file mode 100644 index 8304be26e..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/bson/BsonSimpledCoder.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.bson; - -import org.redkale.convert.SimpledCoder; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - */ -public abstract class BsonSimpledCoder extends SimpledCoder { - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/bson/BsonWriter.java b/android-jdk6-redkale/src/org/redkale/convert/bson/BsonWriter.java deleted file mode 100644 index 895b5525d..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/bson/BsonWriter.java +++ /dev/null @@ -1,298 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.bson; - -import java.nio.*; -import java.util.function.*; -import org.redkale.convert.*; -import org.redkale.util.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public class BsonWriter implements Writer { - - private static final int defaultSize = Integer.getInteger("convert.bson.writer.buffer.defsize", 1024); - - private byte[] content; - - protected int count; - - protected boolean tiny; - - public static ObjectPool createPool(int max) { - return new ObjectPool(max, new Creator() { - - @Override - public BsonWriter create(Object... params) { - return new BsonWriter(); - } - }, null, new Predicate() { - - @Override - public boolean test(BsonWriter t) { - return t.recycle(); - } - }); - } - - public byte[] toArray() { - if (count == content.length) return content; - byte[] newdata = new byte[count]; - System.arraycopy(content, 0, newdata, 0, count); - return newdata; - } - - public ByteBuffer[] toBuffers() { - return new ByteBuffer[]{ByteBuffer.wrap(content, 0, count)}; - } - - protected BsonWriter(byte[] bs) { - this.content = bs; - } - - public BsonWriter() { - this(defaultSize); - } - - public BsonWriter(int size) { - this.content = new byte[size > 128 ? size : 128]; - } - - @Override - public final boolean isTiny() { - return tiny; - } - - public BsonWriter setTiny(boolean tiny) { - this.tiny = tiny; - return this; - } - - //----------------------------------------------------------------------- - //----------------------------------------------------------------------- - /** - * 扩充指定长度的缓冲区 - * - * @param len - * @return - */ - protected int expand(int len) { - int newcount = count + len; - if (newcount <= content.length) return 0; - byte[] newdata = new byte[Math.max(content.length * 3 / 2, newcount)]; - System.arraycopy(content, 0, newdata, 0, count); - this.content = newdata; - return 0; - } - - public void writeTo(final byte ch) { - expand(1); - content[count++] = ch; - } - - public final void writeTo(final byte... chs) { - writeTo(chs, 0, chs.length); - } - - public void writeTo(final byte[] chs, final int start, final int len) { - expand(len); - System.arraycopy(chs, start, content, count, len); - count += len; - } - - protected boolean recycle() { - this.count = 0; - if (this.content.length > defaultSize) { - this.content = new byte[defaultSize]; - } - return true; - } - - @Override - public String toString() { - return this.getClass().getSimpleName() + "[count=" + this.count + "]"; - } - - //------------------------------------------------------------------------ - public final int count() { - return this.count; - } - - @Override - public final void writeBoolean(boolean value) { - writeTo(value ? (byte) 1 : (byte) 0); - } - - @Override - public final void writeByte(byte value) { - writeTo(value); - } - - @Override - public final void writeChar(final char value) { - writeTo((byte) ((value & 0xFF00) >> 8), (byte) (value & 0xFF)); - } - - @Override - public final void writeShort(short value) { - writeTo((byte) (value >> 8), (byte) value); - } - - @Override - public final void writeInt(int value) { - writeTo((byte) (value >> 24), (byte) (value >> 16), (byte) (value >> 8), (byte) value); - } - - @Override - public final void writeLong(long value) { - writeTo((byte) (value >> 56), (byte) (value >> 48), (byte) (value >> 40), (byte) (value >> 32), - (byte) (value >> 24), (byte) (value >> 16), (byte) (value >> 8), (byte) value); - } - - @Override - public final void writeFloat(float value) { - writeInt(Float.floatToIntBits(value)); - } - - @Override - public final void writeDouble(double value) { - writeLong(Double.doubleToLongBits(value)); - } - - @Override - public final void wirteClassName(String clazz) { - writeSmallString(clazz == null ? "" : clazz); - } - - @Override - public final void writeObjectB(int fieldCount, Object obj) { - writeSmallString(""); - writeShort(BsonReader.SIGN_OBJECTB); - } - - @Override - public final void writeObjectE(Object obj) { - writeByte(BsonReader.SIGN_NONEXT); - writeShort(BsonReader.SIGN_OBJECTE); - } - - @Override - public final void writeField(boolean comma, Attribute attribute) { - writeByte(BsonReader.SIGN_HASNEXT); - writeSmallString(attribute.field()); - byte typeval = 127; //字段的类型值 - final Class type = attribute.type(); - if (type == boolean.class || type == Boolean.class) { - typeval = 1; - } else if (type == byte.class || type == Byte.class) { - typeval = 2; - } else if (type == short.class || type == Short.class) { - typeval = 3; - } else if (type == char.class || type == Character.class) { - typeval = 4; - } else if (type == int.class || type == Integer.class) { - typeval = 5; - } else if (type == long.class || type == Long.class) { - typeval = 6; - } else if (type == float.class || type == Float.class) { - typeval = 7; - } else if (type == double.class || type == Double.class) { - typeval = 8; - } else if (type == String.class) { - typeval = 9; - } else if (type == boolean[].class || type == Boolean[].class) { - typeval = 101; - } else if (type == byte[].class || type == Byte[].class) { - typeval = 102; - } else if (type == short[].class || type == Short[].class) { - typeval = 103; - } else if (type == char[].class || type == Character[].class) { - typeval = 104; - } else if (type == int[].class || type == Integer[].class) { - typeval = 105; - } else if (type == long[].class || type == Long[].class) { - typeval = 106; - } else if (type == float[].class || type == Float[].class) { - typeval = 107; - } else if (type == double[].class || type == Double[].class) { - typeval = 108; - } else if (type == String[].class) { - typeval = 109; - } - writeByte(typeval); - } - - /** - * 对于类的字段名、枚举值这些长度一般不超过255且不会出现双字节字符的字符串采用writeSmallString处理, readSmallString用于读取 - * - * @param value - */ - @Override - public final void writeSmallString(String value) { - if (value.isEmpty()) { - writeTo((byte) 0); - return; - } - char[] chars = Utility.charArray(value); - if (chars.length > 255) throw new ConvertException("'" + value + "' has very long length"); - byte[] bytes = new byte[chars.length + 1]; - bytes[0] = (byte) chars.length; - for (int i = 0; i < chars.length; i++) { - if (chars[i] > Byte.MAX_VALUE) throw new ConvertException("'" + value + "' has double-word"); - bytes[i + 1] = (byte) chars[i]; - } - writeTo(bytes); - } - - @Override - public final void writeString(String value) { - if (value == null) { - writeInt(Reader.SIGN_NULL); - return; - } else if (value.isEmpty()) { - writeInt(0); - return; - } - byte[] bytes = Utility.encodeUTF8(value); - writeInt(bytes.length); - writeTo(bytes); - } - - @Override - public final void writeNull() { - writeShort(Reader.SIGN_NULL); - } - - @Override - public final void writeArrayB(int size) { - writeInt(size); - } - - @Override - public final void writeArrayMark() { - } - - @Override - public final void writeArrayE() { - } - - @Override - public void writeMapB(int size) { - writeArrayB(size); - } - - @Override - public final void writeMapMark() { - } - - @Override - public final void writeMapE() { - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/BigIntegerSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/BigIntegerSimpledCoder.java deleted file mode 100644 index f9d076cdf..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/BigIntegerSimpledCoder.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; -import org.redkale.convert.Reader; -import java.math.BigInteger; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class BigIntegerSimpledCoder extends SimpledCoder { - - public static final BigIntegerSimpledCoder instance = new BigIntegerSimpledCoder(); - - @Override - public void convertTo(W out, BigInteger value) { - if (value == null) { - out.writeNull(); - return; - } - ByteArraySimpledCoder.instance.convertTo(out, value.toByteArray()); - } - - @Override - public BigInteger convertFrom(R in) { - byte[] bytes = ByteArraySimpledCoder.instance.convertFrom(in); - return bytes == null ? null : new BigInteger(bytes); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/BoolArraySimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/BoolArraySimpledCoder.java deleted file mode 100644 index 821e74974..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/BoolArraySimpledCoder.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class BoolArraySimpledCoder extends SimpledCoder { - - public static final BoolArraySimpledCoder instance = new BoolArraySimpledCoder(); - - @Override - public void convertTo(W out, boolean[] values) { - if (values == null) { - out.writeNull(); - return; - } - out.writeArrayB(values.length); - boolean flag = false; - for (boolean v : values) { - if (flag) out.writeArrayMark(); - out.writeBoolean(v); - flag = true; - } - out.writeArrayE(); - } - - @Override - public boolean[] convertFrom(R in) { - int len = in.readArrayB(); - if (len == Reader.SIGN_NULL) return null; - if (len == Reader.SIGN_NOLENGTH) { - int size = 0; - boolean[] data = new boolean[8]; - while (in.hasNext()) { - if (size >= data.length) { - boolean[] newdata = new boolean[data.length + 4]; - System.arraycopy(data, 0, newdata, 0, size); - data = newdata; - } - data[size++] = in.readBoolean(); - } - in.readArrayE(); - boolean[] newdata = new boolean[size]; - System.arraycopy(data, 0, newdata, 0, size); - return newdata; - } else { - boolean[] values = new boolean[len]; - for (int i = 0; i < values.length; i++) { - values[i] = in.readBoolean(); - } - in.readArrayE(); - return values; - } - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/BoolSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/BoolSimpledCoder.java deleted file mode 100644 index 90157a266..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/BoolSimpledCoder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class BoolSimpledCoder extends SimpledCoder { - - public static final BoolSimpledCoder instance = new BoolSimpledCoder(); - - @Override - public void convertTo(W out, Boolean value) { - out.writeBoolean(value); - } - - @Override - public Boolean convertFrom(R in) { - return in.readBoolean(); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/ByteArraySimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/ByteArraySimpledCoder.java deleted file mode 100644 index 7349117f7..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/ByteArraySimpledCoder.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class ByteArraySimpledCoder extends SimpledCoder { - - public static final ByteArraySimpledCoder instance = new ByteArraySimpledCoder(); - - @Override - public void convertTo(W out, byte[] values) { - if (values == null) { - out.writeNull(); - return; - } - out.writeArrayB(values.length); - boolean flag = false; - for (byte v : values) { - if (flag) out.writeArrayMark(); - out.writeByte(v); - flag = true; - } - out.writeArrayE(); - } - - @Override - public byte[] convertFrom(R in) { - int len = in.readArrayB(); - if (len == Reader.SIGN_NULL) return null; - if (len == Reader.SIGN_NOLENGTH) { - int size = 0; - byte[] data = new byte[8]; - while (in.hasNext()) { - if (size >= data.length) { - byte[] newdata = new byte[data.length + 4]; - System.arraycopy(data, 0, newdata, 0, size); - data = newdata; - } - data[size++] = in.readByte(); - } - in.readArrayE(); - byte[] newdata = new byte[size]; - System.arraycopy(data, 0, newdata, 0, size); - return newdata; - } else { - byte[] values = new byte[len]; - for (int i = 0; i < values.length; i++) { - values[i] = in.readByte(); - } - in.readArrayE(); - return values; - } - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/ByteSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/ByteSimpledCoder.java deleted file mode 100644 index 9042c29a1..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/ByteSimpledCoder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class ByteSimpledCoder extends SimpledCoder { - - public static final ByteSimpledCoder instance = new ByteSimpledCoder(); - - @Override - public void convertTo(W out, Byte value) { - out.writeByte(value); - } - - @Override - public Byte convertFrom(R in) { - return in.readByte(); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/CharArraySimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/CharArraySimpledCoder.java deleted file mode 100644 index 14ab2e881..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/CharArraySimpledCoder.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class CharArraySimpledCoder extends SimpledCoder { - - public static final CharArraySimpledCoder instance = new CharArraySimpledCoder(); - - @Override - public void convertTo(W out, char[] values) { - if (values == null) { - out.writeNull(); - return; - } - out.writeArrayB(values.length); - boolean flag = false; - for (char v : values) { - if (flag) out.writeArrayMark(); - out.writeChar(v); - flag = true; - } - out.writeArrayE(); - } - - @Override - public char[] convertFrom(R in) { - int len = in.readArrayB(); - if (len == Reader.SIGN_NULL) return null; - if (len == Reader.SIGN_NOLENGTH) { - int size = 0; - char[] data = new char[8]; - while (in.hasNext()) { - if (size >= data.length) { - char[] newdata = new char[data.length + 4]; - System.arraycopy(data, 0, newdata, 0, size); - data = newdata; - } - data[size++] = in.readChar(); - } - in.readArrayE(); - char[] newdata = new char[size]; - System.arraycopy(data, 0, newdata, 0, size); - return newdata; - } else { - char[] values = new char[len]; - for (int i = 0; i < values.length; i++) { - values[i] = in.readChar(); - } - in.readArrayE(); - return values; - } - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/CharSequenceSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/CharSequenceSimpledCoder.java deleted file mode 100644 index f79aa37cf..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/CharSequenceSimpledCoder.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public class CharSequenceSimpledCoder extends SimpledCoder { - - public static final CharSequenceSimpledCoder instance = new CharSequenceSimpledCoder(); - - @Override - public void convertTo(W out, CharSequence value) { - out.writeString(value == null ? null : value.toString()); - } - - @Override - public CharSequence convertFrom(R in) { - return in.readString(); - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/CharSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/CharSimpledCoder.java deleted file mode 100644 index 747b2760a..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/CharSimpledCoder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class CharSimpledCoder extends SimpledCoder { - - public static final CharSimpledCoder instance = new CharSimpledCoder(); - - @Override - public void convertTo(W out, Character value) { - out.writeChar(value); - } - - @Override - public Character convertFrom(R in) { - return in.readChar(); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/CompletionHandlerSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/CompletionHandlerSimpledCoder.java deleted file mode 100644 index fdb3eb6ae..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/CompletionHandlerSimpledCoder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import java.nio.channels.*; -import org.redkale.convert.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class CompletionHandlerSimpledCoder extends SimpledCoder { - - public static final CompletionHandlerSimpledCoder instance = new CompletionHandlerSimpledCoder(); - - @Override - public void convertTo(W out, CompletionHandler value) { - out.writeNull(); - } - - @Override - public CompletionHandler convertFrom(R in) { - in.readObjectB(); - return null; - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/DLongSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/DLongSimpledCoder.java deleted file mode 100644 index d98daad09..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/DLongSimpledCoder.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.Writer; -import org.redkale.convert.SimpledCoder; -import org.redkale.util.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class DLongSimpledCoder extends SimpledCoder { - - private static final ByteArraySimpledCoder bsSimpledCoder = ByteArraySimpledCoder.instance; - - public static final DLongSimpledCoder instance = new DLongSimpledCoder(); - - @Override - public void convertTo(final W out, final DLong value) { - if (value == null) { - out.writeNull(); - } else { - bsSimpledCoder.convertTo(out, value.directBytes()); - } - } - - @Override - public DLong convertFrom(R in) { - byte[] bs = bsSimpledCoder.convertFrom(in); - if (bs == null) return null; - return DLong.create(bs); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/DateSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/DateSimpledCoder.java deleted file mode 100644 index 1da0f693d..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/DateSimpledCoder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; -import java.util.Date; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class DateSimpledCoder extends SimpledCoder { - - public static final DateSimpledCoder instance = new DateSimpledCoder(); - - @Override - public void convertTo(W out, Date value) { - out.writeLong(value.getTime()); - } - - @Override - public Date convertFrom(R in) { - return new Date(in.readLong()); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/DoubleArraySimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/DoubleArraySimpledCoder.java deleted file mode 100644 index cd36fd6a7..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/DoubleArraySimpledCoder.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class DoubleArraySimpledCoder extends SimpledCoder { - - public static final DoubleArraySimpledCoder instance = new DoubleArraySimpledCoder(); - - @Override - public void convertTo(W out, double[] values) { - if (values == null) { - out.writeNull(); - return; - } - out.writeArrayB(values.length); - boolean flag = false; - for (double v : values) { - if (flag) out.writeArrayMark(); - out.writeDouble(v); - flag = true; - } - out.writeArrayE(); - } - - @Override - public double[] convertFrom(R in) { - int len = in.readArrayB(); - if (len == Reader.SIGN_NULL) return null; - if (len == Reader.SIGN_NOLENGTH) { - int size = 0; - double[] data = new double[8]; - while (in.hasNext()) { - if (size >= data.length) { - double[] newdata = new double[data.length + 4]; - System.arraycopy(data, 0, newdata, 0, size); - data = newdata; - } - data[size++] = in.readDouble(); - } - in.readArrayE(); - double[] newdata = new double[size]; - System.arraycopy(data, 0, newdata, 0, size); - return newdata; - } else { - double[] values = new double[len]; - for (int i = 0; i < values.length; i++) { - values[i] = in.readDouble(); - } - in.readArrayE(); - return values; - } - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/DoubleSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/DoubleSimpledCoder.java deleted file mode 100644 index 5b864c6ef..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/DoubleSimpledCoder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class DoubleSimpledCoder extends SimpledCoder { - - public static final DoubleSimpledCoder instance = new DoubleSimpledCoder(); - - @Override - public void convertTo(W out, Double value) { - out.writeDouble(value); - } - - @Override - public Double convertFrom(R in) { - return in.readDouble(); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/EnumSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/EnumSimpledCoder.java deleted file mode 100644 index a988088bd..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/EnumSimpledCoder.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - * @param - */ -public final class EnumSimpledCoder extends SimpledCoder { - - private final Class type; - - public EnumSimpledCoder(Class type) { - this.type = type; - } - - @Override - public void convertTo(final W out, final E value) { - if (value == null) { - out.writeNull(); - } else { - out.writeSmallString(value.toString()); - } - } - - @Override - @SuppressWarnings("unchecked") - public E convertFrom(final R in) { - String value = in.readSmallString(); - if (value == null) return null; - return (E) Enum.valueOf(type, value); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/FloatArraySimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/FloatArraySimpledCoder.java deleted file mode 100644 index e3664a4ad..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/FloatArraySimpledCoder.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class FloatArraySimpledCoder extends SimpledCoder { - - public static final FloatArraySimpledCoder instance = new FloatArraySimpledCoder(); - - @Override - public void convertTo(W out, float[] values) { - if (values == null) { - out.writeNull(); - return; - } - out.writeArrayB(values.length); - boolean flag = false; - for (float v : values) { - if (flag) out.writeArrayMark(); - out.writeFloat(v); - flag = true; - } - out.writeArrayE(); - } - - @Override - public float[] convertFrom(R in) { - int len = in.readArrayB(); - if (len == Reader.SIGN_NULL) return null; - if (len == Reader.SIGN_NOLENGTH) { - int size = 0; - float[] data = new float[8]; - while (in.hasNext()) { - if (size >= data.length) { - float[] newdata = new float[data.length + 4]; - System.arraycopy(data, 0, newdata, 0, size); - data = newdata; - } - data[size++] = in.readFloat(); - } - in.readArrayE(); - float[] newdata = new float[size]; - System.arraycopy(data, 0, newdata, 0, size); - return newdata; - } else { - float[] values = new float[len]; - for (int i = 0; i < values.length; i++) { - values[i] = in.readFloat(); - } - in.readArrayE(); - return values; - } - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/FloatSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/FloatSimpledCoder.java deleted file mode 100644 index 65c86c5dc..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/FloatSimpledCoder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class FloatSimpledCoder extends SimpledCoder { - - public static final FloatSimpledCoder instance = new FloatSimpledCoder(); - - @Override - public void convertTo(W out, Float value) { - out.writeFloat(value); - } - - @Override - public Float convertFrom(R in) { - return in.readFloat(); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/InetAddressSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/InetAddressSimpledCoder.java deleted file mode 100644 index a057cf2b5..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/InetAddressSimpledCoder.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; -import org.redkale.convert.Reader; -import java.net.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class InetAddressSimpledCoder extends SimpledCoder { - - public static final InetAddressSimpledCoder instance = new InetAddressSimpledCoder(); - - @Override - public void convertTo(W out, InetAddress value) { - if (value == null) { - out.writeNull(); - return; - } - ByteArraySimpledCoder.instance.convertTo(out, value.getAddress()); - } - - @Override - public InetAddress convertFrom(R in) { - byte[] bytes = ByteArraySimpledCoder.instance.convertFrom(in); - if (bytes == null) return null; - try { - return InetAddress.getByAddress(bytes); - } catch (Exception ex) { - return null; - } - } - - public final static class InetSocketAddressSimpledCoder extends SimpledCoder { - - public static final InetSocketAddressSimpledCoder instance = new InetSocketAddressSimpledCoder(); - - @Override - public void convertTo(W out, InetSocketAddress value) { - if (value == null) { - out.writeNull(); - return; - } - ByteArraySimpledCoder.instance.convertTo(out, value.getAddress().getAddress()); - out.writeInt(value.getPort()); - } - - @Override - public InetSocketAddress convertFrom(R in) { - byte[] bytes = ByteArraySimpledCoder.instance.convertFrom(in); - if (bytes == null) return null; - int port = in.readInt(); - try { - return new InetSocketAddress(InetAddress.getByAddress(bytes), port); - } catch (Exception ex) { - return null; - } - } - - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/IntArraySimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/IntArraySimpledCoder.java deleted file mode 100644 index 5e9cb18fc..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/IntArraySimpledCoder.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class IntArraySimpledCoder extends SimpledCoder { - - public static final IntArraySimpledCoder instance = new IntArraySimpledCoder(); - - @Override - public void convertTo(W out, int[] values) { - if (values == null) { - out.writeNull(); - return; - } - out.writeArrayB(values.length); - boolean flag = false; - for (int v : values) { - if (flag) out.writeArrayMark(); - out.writeInt(v); - flag = true; - } - out.writeArrayE(); - } - - @Override - public int[] convertFrom(R in) { - int len = in.readArrayB(); - if (len == Reader.SIGN_NULL) return null; - if (len == Reader.SIGN_NOLENGTH) { - int size = 0; - int[] data = new int[8]; - while (in.hasNext()) { - if (size >= data.length) { - int[] newdata = new int[data.length + 4]; - System.arraycopy(data, 0, newdata, 0, size); - data = newdata; - } - data[size++] = in.readInt(); - } - in.readArrayE(); - int[] newdata = new int[size]; - System.arraycopy(data, 0, newdata, 0, size); - return newdata; - } else { - int[] values = new int[len]; - for (int i = 0; i < values.length; i++) { - values[i] = in.readInt(); - } - in.readArrayE(); - return values; - } - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/IntSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/IntSimpledCoder.java deleted file mode 100644 index f007ca0e0..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/IntSimpledCoder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class IntSimpledCoder extends SimpledCoder { - - public static final IntSimpledCoder instance = new IntSimpledCoder(); - - @Override - public void convertTo(W out, Integer value) { - out.writeInt(value); - } - - @Override - public Integer convertFrom(R in) { - return in.readInt(); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/LongArraySimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/LongArraySimpledCoder.java deleted file mode 100644 index 879157c03..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/LongArraySimpledCoder.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class LongArraySimpledCoder extends SimpledCoder { - - public static final LongArraySimpledCoder instance = new LongArraySimpledCoder(); - - @Override - public void convertTo(W out, long[] values) { - if (values == null) { - out.writeNull(); - return; - } - out.writeArrayB(values.length); - boolean flag = false; - for (long v : values) { - if (flag) out.writeArrayMark(); - out.writeLong(v); - flag = true; - } - out.writeArrayE(); - } - - @Override - public long[] convertFrom(R in) { - int len = in.readArrayB(); - if (len == Reader.SIGN_NULL) return null; - if (len == Reader.SIGN_NOLENGTH) { - int size = 0; - long[] data = new long[8]; - while (in.hasNext()) { - if (size >= data.length) { - long[] newdata = new long[data.length + 4]; - System.arraycopy(data, 0, newdata, 0, size); - data = newdata; - } - data[size++] = in.readLong(); - } - in.readArrayE(); - long[] newdata = new long[size]; - System.arraycopy(data, 0, newdata, 0, size); - return newdata; - } else { - long[] values = new long[len]; - for (int i = 0; i < values.length; i++) { - values[i] = in.readLong(); - } - in.readArrayE(); - return values; - } - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/LongSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/LongSimpledCoder.java deleted file mode 100644 index ffbbb9552..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/LongSimpledCoder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class LongSimpledCoder extends SimpledCoder { - - public static final LongSimpledCoder instance = new LongSimpledCoder(); - - @Override - public void convertTo(W out, Long value) { - out.writeLong(value); - } - - @Override - public Long convertFrom(R in) { - return in.readLong(); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/NumberSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/NumberSimpledCoder.java deleted file mode 100644 index 96c5c4dca..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/NumberSimpledCoder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class NumberSimpledCoder extends SimpledCoder { - - public static final NumberSimpledCoder instance = new NumberSimpledCoder(); - - @Override - public void convertTo(W out, Number value) { - out.writeLong(value == null ? 0L : value.longValue()); - } - - @Override - public Number convertFrom(R in) { - return in.readLong(); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/PatternSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/PatternSimpledCoder.java deleted file mode 100644 index c79c72b07..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/PatternSimpledCoder.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import java.util.regex.*; -import org.redkale.convert.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public class PatternSimpledCoder extends SimpledCoder { - - public static final PatternSimpledCoder instance = new PatternSimpledCoder(); - - @Override - public void convertTo(W out, Pattern value) { - if (value == null) { - out.writeNull(); - } else { - out.writeString(value.flags() + "," + value.pattern()); - } - } - - @Override - public Pattern convertFrom(R in) { - String value = in.readString(); - if (value == null) return null; - int pos = value.indexOf(','); - return Pattern.compile(value.substring(pos + 1), Integer.parseInt(value.substring(0, pos))); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/ShortArraySimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/ShortArraySimpledCoder.java deleted file mode 100644 index 5a9cd1929..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/ShortArraySimpledCoder.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class ShortArraySimpledCoder extends SimpledCoder { - - public static final ShortArraySimpledCoder instance = new ShortArraySimpledCoder(); - - @Override - public void convertTo(W out, short[] values) { - if (values == null) { - out.writeNull(); - return; - } - out.writeArrayB(values.length); - boolean flag = false; - for (short v : values) { - if (flag) out.writeArrayMark(); - out.writeShort(v); - flag = true; - } - out.writeArrayE(); - } - - @Override - public short[] convertFrom(R in) { - int len = in.readArrayB(); - if (len == Reader.SIGN_NULL) return null; - if (len == Reader.SIGN_NOLENGTH) { - int size = 0; - short[] data = new short[8]; - while (in.hasNext()) { - if (size >= data.length) { - short[] newdata = new short[data.length + 4]; - System.arraycopy(data, 0, newdata, 0, size); - data = newdata; - } - data[size++] = in.readShort(); - } - in.readArrayE(); - short[] newdata = new short[size]; - System.arraycopy(data, 0, newdata, 0, size); - return newdata; - } else { - short[] values = new short[len]; - for (int i = 0; i < values.length; i++) { - values[i] = in.readShort(); - } - in.readArrayE(); - return values; - } - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/ShortSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/ShortSimpledCoder.java deleted file mode 100644 index 18c7ca5cd..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/ShortSimpledCoder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class ShortSimpledCoder extends SimpledCoder { - - public static final ShortSimpledCoder instance = new ShortSimpledCoder(); - - @Override - public void convertTo(W out, Short value) { - out.writeShort(value); - } - - @Override - public Short convertFrom(R in) { - return in.readShort(); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/StringArraySimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/StringArraySimpledCoder.java deleted file mode 100644 index 4ddc174b3..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/StringArraySimpledCoder.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class StringArraySimpledCoder extends SimpledCoder { - - public static final StringArraySimpledCoder instance = new StringArraySimpledCoder(); - - @Override - public void convertTo(W out, String[] values) { - if (values == null) { - out.writeNull(); - return; - } - out.writeArrayB(values.length); - boolean flag = false; - for (String v : values) { - if (flag) out.writeArrayMark(); - out.writeString(v); - flag = true; - } - out.writeArrayE(); - } - - @Override - public String[] convertFrom(R in) { - int len = in.readArrayB(); - if (len == Reader.SIGN_NULL) return null; - if (len == Reader.SIGN_NOLENGTH) { - int size = 0; - String[] data = new String[8]; - while (in.hasNext()) { - if (size >= data.length) { - String[] newdata = new String[data.length + 4]; - System.arraycopy(data, 0, newdata, 0, size); - data = newdata; - } - data[size++] = in.readString(); - } - in.readArrayE(); - String[] newdata = new String[size]; - System.arraycopy(data, 0, newdata, 0, size); - return newdata; - } else { - String[] values = new String[len]; - for (int i = 0; i < values.length; i++) { - values[i] = in.readString(); - } - in.readArrayE(); - return values; - } - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/StringSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/StringSimpledCoder.java deleted file mode 100644 index f41425233..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/StringSimpledCoder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.SimpledCoder; -import org.redkale.convert.Writer; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class StringSimpledCoder extends SimpledCoder { - - public static final StringSimpledCoder instance = new StringSimpledCoder(); - - @Override - public void convertTo(W out, String value) { - out.writeString(value); - } - - @Override - public String convertFrom(R in) { - return in.readString(); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/ext/TypeSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/ext/TypeSimpledCoder.java deleted file mode 100644 index 0dc4349c9..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/ext/TypeSimpledCoder.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.ext; - -import org.redkale.convert.Reader; -import org.redkale.convert.Writer; -import org.redkale.convert.SimpledCoder; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public class TypeSimpledCoder extends SimpledCoder { - - public static final TypeSimpledCoder instance = new TypeSimpledCoder(); - - @Override - public void convertTo(final W out, final Class value) { - if (value == null) { - out.writeNull(); - } else { - out.writeSmallString(value.getName()); - } - } - - @Override - public Class convertFrom(R in) { - String str = in.readSmallString(); - if (str == null) return null; - try { - return Class.forName(str); - } catch (Exception e) { - return null; - } - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/json/DLongJsonSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/json/DLongJsonSimpledCoder.java deleted file mode 100644 index 3c2770f4d..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/json/DLongJsonSimpledCoder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.json; - -import org.redkale.util.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public class DLongJsonSimpledCoder extends JsonSimpledCoder { - - public static final DLongJsonSimpledCoder instance = new DLongJsonSimpledCoder(); - - @Override - public void convertTo(final JsonWriter out, final DLong value) { - if (value == null) { - out.writeNull(); - } else { - out.writeSmallString(value.toString()); - } - } - - @Override - public DLong convertFrom(JsonReader in) { - final String str = in.readString(); - if (str == null) return null; - return DLong.create(Utility.hexToBin(str)); - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/json/InetAddressJsonSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/json/InetAddressJsonSimpledCoder.java deleted file mode 100644 index d65032255..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/json/InetAddressJsonSimpledCoder.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.json; - -import java.net.*; -import org.redkale.convert.*; -import org.redkale.convert.ext.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public final class InetAddressJsonSimpledCoder extends SimpledCoder { - - public static final InetAddressJsonSimpledCoder instance = new InetAddressJsonSimpledCoder(); - - @Override - public void convertTo(JsonWriter out, InetAddress value) { - if (value == null) { - out.writeNull(); - return; - } - StringSimpledCoder.instance.convertTo(out, value.getHostAddress()); - } - - @Override - public InetAddress convertFrom(JsonReader in) { - String str = StringSimpledCoder.instance.convertFrom(in); - if (str == null) return null; - try { - return InetAddress.getByName(str); - } catch (Exception ex) { - return null; - } - } - - public final static class InetSocketAddressJsonSimpledCoder extends SimpledCoder { - - public static final InetSocketAddressJsonSimpledCoder instance = new InetSocketAddressJsonSimpledCoder(); - - @Override - public void convertTo(JsonWriter out, InetSocketAddress value) { - if (value == null) { - out.writeNull(); - return; - } - StringSimpledCoder.instance.convertTo(out, value.getHostString() + ":" + value.getPort()); - } - - @Override - public InetSocketAddress convertFrom(JsonReader in) { - String str = StringSimpledCoder.instance.convertFrom(in); - if (str == null) return null; - try { - int pos = str.indexOf(':'); - return new InetSocketAddress(str.substring(0, pos), Integer.parseInt(str.substring(pos + 1))); - } catch (Exception ex) { - return null; - } - } - - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/json/JsonByteBufferWriter.java b/android-jdk6-redkale/src/org/redkale/convert/json/JsonByteBufferWriter.java deleted file mode 100644 index 1249de9ca..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/json/JsonByteBufferWriter.java +++ /dev/null @@ -1,349 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.json; - -import java.nio.*; -import java.nio.charset.*; -import java.util.*; -import java.util.function.*; -import org.redkale.util.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public final class JsonByteBufferWriter extends JsonWriter { - - private static final Charset UTF8 = Charset.forName("UTF-8"); - - private final Charset charset; - - private final Supplier supplier; - - private ByteBuffer[] buffers; - - private int index; - - protected JsonByteBufferWriter(Supplier supplier) { - this(null, supplier); - } - - protected JsonByteBufferWriter(Charset charset, Supplier supplier) { - this.charset = UTF8.equals(charset) ? null : charset; - this.supplier = supplier; - } - - @Override - public JsonByteBufferWriter setTiny(boolean tiny) { - this.tiny = tiny; - return this; - } - - @Override - protected boolean recycle() { - this.index = 0; - this.buffers = null; - return false; - } - - @Override - public ByteBuffer[] toBuffers() { - if (buffers == null) return new ByteBuffer[0]; - for (int i = index; i < this.buffers.length; i++) { - ByteBuffer buf = this.buffers[i]; - if (buf.position() != 0) buf.flip(); - } - return this.buffers; - } - - @Override - public int count() { - if (this.buffers == null) return 0; - int len = 0; - for (ByteBuffer buffer : buffers) { - len += buffer.remaining(); - } - return len; - } - - private int expand(final int byteLength) { - if (this.buffers == null) { - this.index = 0; - this.buffers = new ByteBuffer[]{supplier.get()}; - } - ByteBuffer buffer = this.buffers[index]; - if (!buffer.hasRemaining()) { - buffer.flip(); - buffer = supplier.get(); - ByteBuffer[] bufs = new ByteBuffer[this.buffers.length + 1]; - System.arraycopy(this.buffers, 0, bufs, 0, this.buffers.length); - bufs[this.buffers.length] = buffer; - this.buffers = bufs; - this.index++; - } - int len = buffer.remaining(); - int size = 0; - while (len < byteLength) { - buffer = supplier.get(); - ByteBuffer[] bufs = new ByteBuffer[this.buffers.length + 1]; - System.arraycopy(this.buffers, 0, bufs, 0, this.buffers.length); - bufs[this.buffers.length] = buffer; - this.buffers = bufs; - len += buffer.remaining(); - size++; - } - return size; - } - - @Override - public void writeTo(final char ch) { - if (ch > Byte.MAX_VALUE) throw new RuntimeException("writeTo char(int.value = " + (int) ch + ") must be less 127"); - expand(1); - this.buffers[index].put((byte) ch); - } - - @Override - public void writeTo(final char[] chs, final int start, final int len) { - writeTo(-1, false, chs, start, len); - } - - private void writeTo(int expandsize, final boolean quote, final char[] chs, final int start, final int len) { - int byteLength = quote ? 2 : 0; - ByteBuffer bb = null; - if (charset == null) { - byteLength += encodeUTF8Length(chs, start, len); - } else { - bb = charset.encode(CharBuffer.wrap(chs, start, len)); - byteLength += bb.remaining(); - } - if (expandsize < 0) expandsize = expand(byteLength); - if (expandsize == 0) { // 只需要一个buffer - final ByteBuffer buffer = this.buffers[index]; - if (quote) buffer.put((byte) '"'); - - if (charset == null) { //UTF-8 - final int limit = start + len; - for (int i = start; i < limit; i++) { - char c = chs[i]; - if (c < 0x80) { - buffer.put((byte) c); - } else if (c < 0x800) { - buffer.put((byte) (0xc0 | (c >> 6))); - buffer.put((byte) (0x80 | (c & 0x3f))); - } else { - buffer.put((byte) (0xe0 | ((c >> 12)))); - buffer.put((byte) (0x80 | ((c >> 6) & 0x3f))); - buffer.put((byte) (0x80 | (c & 0x3f))); - } - } - } else { - buffer.put(bb); - } - - if (quote) buffer.put((byte) '"'); - return; - } - ByteBuffer buffer = this.buffers[index]; - if (quote) { - if (!buffer.hasRemaining()) buffer = nextByteBuffer(); - buffer.put((byte) '"'); - } - if (charset == null) { //UTF-8 - final int limit = start + len; - for (int i = start; i < limit; i++) { - buffer = putChar(buffer, chs[i]); - } - } else { - while (bb.hasRemaining()) { - if (!buffer.hasRemaining()) buffer = nextByteBuffer(); - buffer.put(bb.get()); - } - } - if (quote) { - if (!buffer.hasRemaining()) buffer = nextByteBuffer(); - buffer.put((byte) '"'); - } - } - - private ByteBuffer putChar(ByteBuffer buffer, char c) { - if (c < 0x80) { - if (!buffer.hasRemaining()) buffer = nextByteBuffer(); - buffer.put((byte) c); - } else if (c < 0x800) { - if (!buffer.hasRemaining()) buffer = nextByteBuffer(); - buffer.put((byte) (0xc0 | (c >> 6))); - if (!buffer.hasRemaining()) buffer = nextByteBuffer(); - buffer.put((byte) (0x80 | (c & 0x3f))); - } else { - if (!buffer.hasRemaining()) buffer = nextByteBuffer(); - buffer.put((byte) (0xe0 | ((c >> 12)))); - if (!buffer.hasRemaining()) buffer = nextByteBuffer(); - buffer.put((byte) (0x80 | ((c >> 6) & 0x3f))); - if (!buffer.hasRemaining()) buffer = nextByteBuffer(); - buffer.put((byte) (0x80 | (c & 0x3f))); - } - return buffer; - } - - private ByteBuffer nextByteBuffer() { - this.buffers[this.index].flip(); - return this.buffers[++this.index]; - } - - private static int encodeUTF8Length(final char[] text, final int start, final int len) { - char c; - int size = 0; - final char[] chars = text; - final int limit = start + len; - for (int i = start; i < limit; i++) { - c = chars[i]; - size += (c < 0x80 ? 1 : (c < 0x800 ? 2 : 3)); - } - return size; - } - - private static int encodeEscapeUTF8Length(final char[] text, final int start, final int len) { - char c; - int size = 0; - final char[] chars = text; - final int limit = start + len; - for (int i = start; i < limit; i++) { - c = chars[i]; - switch (c) { - case '\n': size += 2; - break; - case '\r': size += 2; - break; - case '\t': size += 2; - break; - case '\\': size += 2; - break; - case '"': size += 2; - break; - default: - size += (c < 0x80 ? 1 : (c < 0x800 ? 2 : 3)); - break; - } - } - return size; - } - - /** - * 注意: 该String值不能为null且不会进行转义, 只用于不含需要转义字符的字符串,例如enum、double、BigInteger转换的String - * - * @param quote - * @param value - */ - @Override - public void writeTo(final boolean quote, final String value) { - char[] chs = Utility.charArray(value); - writeTo(-1, quote, chs, 0, chs.length); - } - - @Override - public void writeString(String value) { - if (value == null) { - writeNull(); - return; - } - final char[] chs = Utility.charArray(value); - int len = 0; - for (char ch : chs) { - switch (ch) { - case '\n': len += 2; - break; - case '\r': len += 2; - break; - case '\t': len += 2; - break; - case '\\': len += 2; - break; - case '"': len += 2; - break; - default: len++; - break; - } - } - if (len == chs.length) { - writeTo(-1, true, chs, 0, len); - return; - } - int expandsize = -1; - if (this.charset == null) { //UTF-8 - final int byteLength = 2 + encodeEscapeUTF8Length(chs, 0, chs.length); - expandsize = expand(byteLength); - if (expandsize == 0) { // 只需要一个buffer - final ByteBuffer buffer = this.buffers[index]; - buffer.put((byte) '"'); - for (char c : chs) { - switch (c) { - case '\n': buffer.put((byte) '\\').put((byte) 'n'); - break; - case '\r': buffer.put((byte) '\\').put((byte) 'r'); - break; - case '\t': buffer.put((byte) '\\').put((byte) 't'); - break; - case '\\': buffer.put((byte) '\\').put((byte) '\\'); - break; - case '"': buffer.put((byte) '\\').put((byte) '"'); - break; - default: - if (c < 0x80) { - buffer.put((byte) c); - } else if (c < 0x800) { - buffer.put((byte) (0xc0 | (c >> 6))); - buffer.put((byte) (0x80 | (c & 0x3f))); - } else { - buffer.put((byte) (0xe0 | ((c >> 12)))); - buffer.put((byte) (0x80 | ((c >> 6) & 0x3f))); - buffer.put((byte) (0x80 | (c & 0x3f))); - } - break; - } - } - buffer.put((byte) '"'); - return; - } - } - StringBuilder sb = new StringBuilder(len); - for (char ch : chs) { - switch (ch) { - case '\n': sb.append("\\n"); - break; - case '\r': sb.append("\\r"); - break; - case '\t': sb.append("\\t"); - break; - case '\\': sb.append("\\\\"); - break; - case '"': sb.append("\\\""); - break; - default: sb.append(ch); - break; - } - } - char[] cs = Utility.charArray(sb); - writeTo(expandsize, true, cs, 0, sb.length()); - } - - @Override - public void writeField(boolean comma, Attribute attribute) { - if (comma) writeTo(','); - writeTo(true, attribute.field()); - writeTo(':'); - } - - @Override - public void writeSmallString(String value) { - writeTo(false, value); - } - - @Override - public String toString() { - return Objects.toString(this); - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/json/JsonConvert.java b/android-jdk6-redkale/src/org/redkale/convert/json/JsonConvert.java deleted file mode 100644 index 4f7089ad5..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/json/JsonConvert.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.json; - -import java.lang.reflect.*; -import java.nio.*; -import java.nio.charset.*; -import java.util.function.*; -import org.redkale.convert.*; -import org.redkale.util.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -@SuppressWarnings("unchecked") -public final class JsonConvert extends Convert { - - public static final Type TYPE_MAP_STRING_STRING = new TypeToken>() { - }.getType(); - - private static final ObjectPool readerPool = JsonReader.createPool(Integer.getInteger("convert.json.pool.size", 16)); - - private static final ObjectPool writerPool = JsonWriter.createPool(Integer.getInteger("convert.json.pool.size", 16)); - - private final boolean tiny; - - protected JsonConvert(JsonFactory factory, boolean tiny) { - super(factory); - this.tiny = tiny; - } - - public JsonByteBufferWriter pollJsonWriter(final Supplier supplier) { - return new JsonByteBufferWriter(supplier).setTiny(tiny); - } - - public JsonByteBufferWriter pollJsonWriter(final Charset charset, final Supplier supplier) { - return new JsonByteBufferWriter(charset, supplier).setTiny(tiny); - } - - public JsonWriter pollJsonWriter() { - return writerPool.get().setTiny(tiny); - } - - public void offerJsonWriter(JsonWriter out) { - if (out != null) writerPool.offer(out); - } - - @Override - public JsonFactory getFactory() { - return (JsonFactory) factory; - } - - public T convertFrom(final Type type, final String text) { - if (text == null) return null; - return convertFrom(type, Utility.charArray(text)); - } - - public T convertFrom(final Type type, final char[] text) { - if (text == null) return null; - return convertFrom(type, text, 0, text.length); - } - - public T convertFrom(final Type type, final char[] text, int start, int len) { - if (text == null || type == null) return null; - final JsonReader in = readerPool.get(); - in.setText(text, start, len); - T rs = (T) factory.loadDecoder(type).convertFrom(in); - readerPool.offer(in); - return rs; - } - - public String convertTo(final Type type, Object value) { - if (type == null) return null; - if (value == null) return "null"; - final JsonWriter out = writerPool.get().setTiny(tiny); - factory.loadEncoder(type).convertTo(out, value); - String result = out.toString(); - writerPool.offer(out); - return result; - } - - public String convertTo(Object value) { - if (value == null) return "null"; - return convertTo(value.getClass(), value); - } - - public void convertTo(final JsonWriter out, final Type type, Object value) { - if (type == null) return; - if (value == null) { - out.writeNull(); - } else { - factory.loadEncoder(type).convertTo(out, value); - } - } - - public void convertTo(final JsonWriter out, Object value) { - if (value == null) { - out.writeNull(); - } else { - factory.loadEncoder(value.getClass()).convertTo(out, value); - } - } - - public ByteBuffer[] convertTo(final Supplier supplier, final Type type, Object value) { - return convertTo(null, supplier, type, value); - } - - public ByteBuffer[] convertTo(final Charset charset, final Supplier supplier, final Type type, Object value) { - if (supplier == null || type == null) return null; - JsonByteBufferWriter out = new JsonByteBufferWriter(charset, supplier); - if (value == null) { - out.writeNull(); - } else { - factory.loadEncoder(type).convertTo(out, value); - } - return out.toBuffers(); - } - - public ByteBuffer[] convertTo(final Supplier supplier, Object value) { - return convertTo(null, supplier, value); - } - - public ByteBuffer[] convertTo(final Charset charset, final Supplier supplier, Object value) { - if (supplier == null) return null; - JsonByteBufferWriter out = new JsonByteBufferWriter(charset, supplier); - if (value == null) { - out.writeNull(); - } else { - factory.loadEncoder(value.getClass()).convertTo(out, value); - } - return out.toBuffers(); - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/json/JsonFactory.java b/android-jdk6-redkale/src/org/redkale/convert/json/JsonFactory.java deleted file mode 100644 index 88753f691..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/json/JsonFactory.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.json; - -import org.redkale.convert.ConvertType; -import org.redkale.convert.Factory; -import java.io.Serializable; -import java.net.*; -import org.redkale.util.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public final class JsonFactory extends Factory { - - private static final JsonFactory instance = new JsonFactory(null, Boolean.getBoolean("convert.json.tiny")); - - static { - instance.register(InetAddress.class, InetAddressJsonSimpledCoder.instance); - instance.register(InetSocketAddress.class, InetAddressJsonSimpledCoder.InetSocketAddressJsonSimpledCoder.instance); - instance.register(DLong.class, DLongJsonSimpledCoder.instance); - instance.register(Serializable.class, instance.loadEncoder(Object.class)); - } - - private JsonFactory(JsonFactory parent, boolean tiny) { - super(parent, tiny); - } - - public static JsonFactory root() { - return instance; - } - - @Override - public final JsonConvert getConvert() { - if (convert == null) convert = new JsonConvert(this, tiny); - return (JsonConvert) convert; - } - - @Override - public JsonFactory createChild() { - return new JsonFactory(this, this.tiny); - } - - @Override - public JsonFactory createChild(boolean tiny) { - return new JsonFactory(this, tiny); - } - - @Override - public ConvertType getConvertType() { - return ConvertType.JSON; - } - - @Override - public boolean isReversible() { - return false; - } -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/json/JsonReader.java b/android-jdk6-redkale/src/org/redkale/convert/json/JsonReader.java deleted file mode 100644 index 1789faa0e..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/json/JsonReader.java +++ /dev/null @@ -1,578 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.json; - -import java.util.concurrent.atomic.*; -import java.util.function.*; -import org.redkale.convert.*; -import static org.redkale.convert.Reader.*; -import org.redkale.util.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public final class JsonReader implements Reader { - - private int position = -1; - - private char[] text; - - private int limit; - - public static ObjectPool createPool(int max) { - return new ObjectPool(max, new Creator() { //为了兼容 JDK 6 - - @Override - public JsonReader create(Object... params) { - return new JsonReader(); - } - }, null, new Predicate() { - - @Override - public boolean test(JsonReader t) { - return t.recycle(); - } - }); - } - - public JsonReader() { - } - - public JsonReader(String json) { - setText(Utility.charArray(json)); - } - - public JsonReader(char[] text) { - setText(text, 0, text.length); - } - - public JsonReader(char[] text, int start, int len) { - setText(text, start, len); - } - - public final void setText(String text) { - JsonReader.this.setText(Utility.charArray(text)); - } - - public final void setText(char[] text) { - setText(text, 0, text.length); - } - - public final void setText(char[] text, int start, int len) { - this.text = text; - this.position = start - 1; - this.limit = start + len - 1; - } - - protected boolean recycle() { - this.position = -1; - this.limit = -1; - this.text = null; - return true; - } - - public void close() { - this.recycle(); - } - - /** - * 找到指定的属性值 例如: {id : 1, data : { name : 'a', items : [1,2,3]}} seek('data.items') 直接跳转到 [1,2,3]; - * - * @param key - */ - public final void seek(String key) { - if (key == null || key.length() < 1) return; - final String[] keys = key.split("\\."); - nextGoodChar(); //读掉 { [ - for (String key1 : keys) { - while (this.hasNext()) { - String field = this.readSmallString(); - skipBlank(); - if (key1.equals(field)) break; - skipValue(); - } - } - - } - - /** - * 跳过属性的值 - */ - @Override - public final void skipValue() { - final char ch = nextGoodChar(); - if (ch == '"' || ch == '\'') { - backChar(ch); - readString(); - } else if (ch == '{') { - while (hasNext()) { - this.readSmallString(); //读掉field - this.skipBlank(); - this.skipValue(); - } - } else if (ch == '[') { - while (hasNext()) { - this.skipValue(); - } - } else { - char c; - for (;;) { - c = nextChar(); - if (c <= ' ') return; - if (c == '}' || c == ']' || c == ',' || c == ':') { - backChar(c); - return; - } - } - } - } - - /** - * 读取下一个字符, 不跳过空白字符 - * - * @return - */ - protected char nextChar() { - return this.text[++this.position]; - } - - /** - * 跳过空白字符, 返回一个非空白字符 - * - * @return - */ - protected char nextGoodChar() { - char c = nextChar(); - if (c > ' ') return c; - for (;;) { - c = nextChar(); - if (c > ' ') return c; - } - } - - /** - * 回退最后读取的字符 - * - * @param ch - */ - protected void backChar(char ch) { - this.position--; - } - - /** - * 判断下一个非空白字符是否为{ - * - */ - @Override - public int readObjectB() { - char ch = this.text[++this.position]; - if (ch == '{') return SIGN_NOLENGTH; - if (ch <= ' ') { - for (;;) { - ch = this.text[++this.position]; - if (ch > ' ') break; - } - if (ch == '{') return SIGN_NOLENGTH; - } - if (ch == 'n' && text[++position] == 'u' && text[++position] == 'l' && text[++position] == 'l') return SIGN_NULL; - if (ch == 'N' && text[++position] == 'U' && text[++position] == 'L' && text[++position] == 'L') return SIGN_NULL; - throw new ConvertException("a json object text must begin with '{' (position = " + position + ") but '" + ch + "' in (" + new String(this.text) + ")"); - } - - @Override - public void readObjectE() { - } - - /** - * 判断下一个非空白字符是否为{ - * - */ - @Override - public int readMapB() { - return readArrayB(); - } - - @Override - public void readMapE() { - } - - /** - * 判断下一个非空白字符是否为[ - * - * @return - */ - @Override - public int readArrayB() { - char ch = this.text[++this.position]; - if (ch == '[') return SIGN_NOLENGTH; - if (ch == '{') return SIGN_NOLENGTH; - if (ch <= ' ') { - for (;;) { - ch = this.text[++this.position]; - if (ch > ' ') break; - } - if (ch == '[') return SIGN_NOLENGTH; - if (ch == '{') return SIGN_NOLENGTH; - } - if (ch == 'n' && text[++position] == 'u' && text[++position] == 'l' && text[++position] == 'l') return SIGN_NULL; - if (ch == 'N' && text[++position] == 'U' && text[++position] == 'L' && text[++position] == 'L') return SIGN_NULL; - throw new ConvertException("a json array text must begin with '[' (position = " + position + ") but '" + ch + "' in (" + new String(this.text) + ")"); - } - - @Override - public void readArrayE() { - } - - /** - * 判断下一个非空白字符是否: - */ - @Override - public void skipBlank() { - char ch = this.text[++this.position]; - if (ch == ':') return; - if (ch <= ' ') { - for (;;) { - ch = this.text[++this.position]; - if (ch > ' ') break; - } - if (ch == ':') return; - } - throw new ConvertException("'" + new String(text) + "'expected a ':' but '" + ch + "'(position = " + position + ") in (" + new String(this.text) + ")"); - } - - /** - * 判断对象是否存在下一个属性或者数组是否存在下一个元素 - * - * @return - */ - @Override - public boolean hasNext() { - char ch = this.text[++this.position]; - if (ch == ',') return true; - if (ch == '}' || ch == ']') return false; - if (ch <= ' ') { - for (;;) { - ch = this.text[++this.position]; - if (ch > ' ') break; - } - if (ch == ',') return true; - if (ch == '}' || ch == ']') return false; - } - this.position--; - return true; - } - - @Override - public String readClassName() { - return null; - } - - @Override - public String readSmallString() { - final int eof = this.limit; - if (this.position == eof) return null; - final char[] text0 = this.text; - int currpos = this.position; - char ch = text0[++currpos]; - if (ch <= ' ') { - for (;;) { - ch = text0[++currpos]; - if (ch > ' ') break; - } - } - if (ch == '"' || ch == '\'') { - final char quote = ch; - final int start = currpos + 1; - for (;;) { - ch = text0[++currpos]; - if (ch == '\\') { - this.position = currpos - 1; - return readEscapeValue(quote, start); - } else if (ch == quote) { - break; - } - } - this.position = currpos; - char[] chs = new char[currpos - start]; - System.arraycopy(text0, start, chs, 0, chs.length); - return new String(chs); - } else { - int start = currpos; - for (;;) { - if (currpos == eof) break; - ch = text0[++currpos]; - if (ch == ',' || ch == ']' || ch == '}' || ch <= ' ' || ch == ':') break; - } - int len = currpos - start; - if (len < 1) { - this.position = currpos; - return String.valueOf(ch); - } - this.position = currpos - 1; - if (len == 4 && text0[start] == 'n' && text0[start + 1] == 'u' && text0[start + 2] == 'l' && text0[start + 3] == 'l') return null; - return new String(text0, start, len); - } - } - - /** - * 读取一个int - * - * @return - */ - @Override - public final int readInt() { - final char[] text0 = this.text; - final int eof = this.limit; - int currpos = this.position; - char firstchar = text0[++currpos]; - if (firstchar <= ' ') { - for (;;) { - firstchar = text0[++currpos]; - if (firstchar > ' ') break; - } - } - if (firstchar == '"' || firstchar == '\'') { - firstchar = text0[++currpos]; - if (firstchar == '"' || firstchar == '\'') { - this.position = currpos; - return 0; - } - } - int value = 0; - final boolean negative = firstchar == '-'; - if (!negative) { - if (firstchar < '0' || firstchar > '9') throw new NumberFormatException("illegal escape(" + firstchar + ") (position = " + currpos + ") in (" + new String(this.text) + ")"); - value = firstchar - '0'; - } - for (;;) { - if (currpos == eof) break; - char ch = text0[++currpos]; - if (ch >= '0' && ch <= '9') { - value = (value << 3) + (value << 1) + (ch - '0'); - } else if (ch == '"' || ch == '\'') { - } else if (ch == ',' || ch == '}' || ch == ']' || ch <= ' ' || ch == ':') { - break; - } else { - throw new NumberFormatException("illegal escape(" + ch + ") (position = " + currpos + ") in (" + new String(this.text) + ")"); - } - } - this.position = currpos - 1; - return negative ? -value : value; - } - - /** - * 读取一个long - * - * @return - */ - @Override - public final long readLong() { - final char[] text0 = this.text; - final int eof = this.limit; - int currpos = this.position; - char firstchar = text0[++currpos]; - if (firstchar <= ' ') { - for (;;) { - firstchar = text0[++currpos]; - if (firstchar > ' ') break; - } - } - if (firstchar == '"' || firstchar == '\'') { - firstchar = text0[++currpos]; - if (firstchar == '"' || firstchar == '\'') { - this.position = currpos; - return 0L; - } - } - long value = 0; - final boolean negative = firstchar == '-'; - if (!negative) { - if (firstchar < '0' || firstchar > '9') throw new NumberFormatException("illegal escape(" + firstchar + ") (position = " + currpos + ") in (" + new String(this.text) + ")"); - value = firstchar - '0'; - } - for (;;) { - if (currpos == eof) break; - char ch = text0[++currpos]; - if (ch >= '0' && ch <= '9') { - value = (value << 3) + (value << 1) + (ch - '0'); - } else if (ch == '"' || ch == '\'') { - } else if (ch == ',' || ch == '}' || ch == ']' || ch <= ' ' || ch == ':') { - break; - } else { - throw new NumberFormatException("illegal escape(" + ch + ") (position = " + currpos + ") but '" + ch + "' in (" + new String(this.text) + ")"); - } - } - this.position = currpos - 1; - return negative ? -value : value; - } - - @Override - public DeMember readField(final AtomicInteger index, final DeMember[] members) { - final String exceptedfield = this.readSmallString(); - final int len = members.length; - int v = index.get(); - if (v >= len) { - v = 0; - index.set(0); - } - for (int k = v; k < len; k++) { - if (exceptedfield.equals(members[k].getAttribute().field())) { - index.set(k); - return members[k]; - } - } - for (int k = 0; k < v; k++) { - if (exceptedfield.equals(members[k].getAttribute().field())) { - index.set(k); - return members[k]; - } - } - return null; - //if (result == null && len == 1 && text0[start] == '@') return REFER; - } -//------------------------------------------------------------ - - @Override - public boolean readBoolean() { - return "true".equalsIgnoreCase(this.readSmallString()); - } - - @Override - public byte readByte() { - return (byte) readInt(); - } - - @Override - public char readChar() { - return (char) readInt(); - } - - @Override - public short readShort() { - return (short) readInt(); - } - - @Override - public float readFloat() { - String chars = readSmallString(); - if (chars == null || chars.isEmpty()) return 0.f; - return Float.parseFloat(chars); - } - - @Override - public double readDouble() { - String chars = readSmallString(); - if (chars == null || chars.isEmpty()) return 0.0; - return Double.parseDouble(chars); - } - - /** - * 读取字符串, 必须是"或者'包围的字符串值 - * - * @return - */ - @Override - public String readString() { - final char[] text0 = this.text; - int currpos = this.position; - char expected = text0[++currpos]; - if (expected <= ' ') { - for (;;) { - expected = text0[++currpos]; - if (expected > ' ') break; - } - } - if (expected != '"' && expected != '\'') { - if (expected == 'n' && text0.length > currpos + 3) { - if (text0[++currpos] == 'u' && text0[++currpos] == 'l' && text0[++currpos] == 'l') { - this.position = currpos; - if (text0.length > currpos + 4) { - char ch = text0[currpos + 1]; - if (ch == ',' || ch <= ' ' || ch == '}' || ch == ']' || ch == ':') return null; - } else { - return null; - } - } - } else { - final int start = currpos; - for (;;) { - char ch = text0[currpos]; - if (ch == ',' || ch <= ' ' || ch == '}' || ch == ']' || ch == ':') break; - currpos++; - } - if (currpos == start) throw new ConvertException("expected a string after a key but '" + text0[position] + "' (position = " + position + ") in (" + new String(this.text) + ")"); - this.position = currpos - 1; - return new String(text0, start, currpos - start); - } - this.position = currpos; - throw new ConvertException("expected a ':' after a key but '" + text0[position] + "' (position = " + position + ") in (" + new String(this.text) + ")"); - } - final int start = ++currpos; - for (;;) { - char ch = text0[currpos]; - if (ch == expected) { - break; - } else if (ch == '\\') { - this.position = currpos - 1; - return readEscapeValue(expected, start); - } - currpos++; - } - this.position = currpos; - return new String(text0, start, currpos - start); - } - - private String readEscapeValue(final char expected, int start) { - StringBuilder array = new StringBuilder(); - final char[] text0 = this.text; - int pos = this.position; - array.append(text0, start, pos + 1 - start); - char c; - for (;;) { - c = text0[++pos]; - if (c == expected) { - this.position = pos; - return array.toString(); - } else if (c == '\\') { - c = text0[++pos]; - switch (c) { - case '"': - case '\'': - case '\\': - case '/': - array.append(c); - break; - case 'n': - array.append('\n'); - break; - case 'r': - array.append('\r'); - break; - case 'u': - array.append((char) Integer.parseInt(new String(new char[]{text0[++pos], text0[++pos], text0[++pos], text0[++pos]}), 16)); - break; - case 't': - array.append('\t'); - break; - case 'b': - array.append('\b'); - break; - case 'f': - array.append('\f'); - break; - default: - this.position = pos; - throw new ConvertException("illegal escape(" + c + ") (position = " + this.position + ") in (" + new String(this.text) + ")"); - } - } else { - array.append(c); - } - } - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/json/JsonSimpledCoder.java b/android-jdk6-redkale/src/org/redkale/convert/json/JsonSimpledCoder.java deleted file mode 100644 index d8049e80c..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/json/JsonSimpledCoder.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.json; - -import org.redkale.convert.SimpledCoder; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - */ -public abstract class JsonSimpledCoder extends SimpledCoder { - -} diff --git a/android-jdk6-redkale/src/org/redkale/convert/json/JsonWriter.java b/android-jdk6-redkale/src/org/redkale/convert/json/JsonWriter.java deleted file mode 100644 index f97b7b29b..000000000 --- a/android-jdk6-redkale/src/org/redkale/convert/json/JsonWriter.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.convert.json; - -import java.nio.*; -import java.util.function.*; -import org.redkale.convert.*; -import org.redkale.util.*; - -/** - * - * writeTo系列的方法输出的字符不能含特殊字符 - * - * @see http://www.redkale.org - * @author zhangjx - */ -public class JsonWriter implements Writer { - - private static final char[] CHARS_TUREVALUE = "true".toCharArray(); - - private static final char[] CHARS_FALSEVALUE = "false".toCharArray(); - - private static final int defaultSize = Integer.getInteger("convert.json.writer.buffer.defsize", 1024); - - private int count; - - private char[] content; - - protected boolean tiny; - - public static ObjectPool createPool(int max) { - return new ObjectPool(max, new Creator() { - - @Override - public JsonWriter create(Object... params) { - return new JsonWriter(); - } - }, null, new Predicate() { - - @Override - public boolean test(JsonWriter t) { - return t.recycle(); - } - }); - } - - public JsonWriter() { - this(defaultSize); - } - - public JsonWriter(int size) { - this.content = new char[size > 128 ? size : 128]; - } - - @Override - public boolean isTiny() { - return tiny; - } - - public JsonWriter setTiny(boolean tiny) { - this.tiny = tiny; - return this; - } - - //----------------------------------------------------------------------- - //----------------------------------------------------------------------- - /** - * 返回指定至少指定长度的缓冲区 - * - * @param len - * @return - */ - private char[] expand(int len) { - int newcount = count + len; - if (newcount <= content.length) return content; - char[] newdata = new char[Math.max(content.length * 3 / 2, newcount)]; - System.arraycopy(content, 0, newdata, 0, count); - this.content = newdata; - return newdata; - } - - public void writeTo(final char ch) { //只能是 0 - 127 的字符 - expand(1); - content[count++] = ch; - } - - public void writeTo(final char[] chs, final int start, final int len) { //只能是 0 - 127 的字符 - expand(len); - System.arraycopy(chs, start, content, count, len); - count += len; - } - - /** - * 注意: 该String值不能为null且不会进行转义, 只用于不含需要转义字符的字符串,例如enum、double、BigInteger转换的String - * - * @param quote - * @param value - */ - public void writeTo(final boolean quote, final String value) { - int len = value.length(); - expand(len + (quote ? 2 : 0)); - if (quote) content[count++] = '"'; - value.getChars(0, len, content, count); - count += len; - if (quote) content[count++] = '"'; - } - - protected boolean recycle() { - this.count = 0; - if (this.content.length > defaultSize) { - this.content = new char[defaultSize]; - } - return true; - } - - public ByteBuffer[] toBuffers() { - return new ByteBuffer[]{ByteBuffer.wrap(Utility.encodeUTF8(content, 0, count))}; - } - - public int count() { - return this.count; - } - - @Override - public void writeString(String value) { - if (value == null) { - writeNull(); - return; - } - expand(value.length() * 2 + 2); - content[count++] = '"'; - for (char ch : Utility.charArray(value)) { - switch (ch) { - case '\n': content[count++] = '\\'; - content[count++] = 'n'; - break; - case '\r': content[count++] = '\\'; - content[count++] = 'r'; - break; - case '\t': content[count++] = '\\'; - content[count++] = 't'; - break; - case '\\': content[count++] = '\\'; - content[count++] = ch; - break; - case '"': content[count++] = '\\'; - content[count++] = ch; - break; - default: content[count++] = ch; - break; - } - } - content[count++] = '"'; - } - - @Override - public void writeField(boolean comma, Attribute attribute) { - if (comma) writeTo(','); - writeTo(true, attribute.field()); - writeTo(':'); - } - - @Override - public void writeSmallString(String value) { - writeTo(true, value); - } - - @Override - public String toString() { - return new String(content, 0, count); - } - - //---------------------------------------------------------------------------------------------- - public final void writeTo(final char... chs) { //只能是 0 - 127 的字符 - writeTo(chs, 0, chs.length); - } - - @Override - public final void writeBoolean(boolean value) { - writeTo(value ? CHARS_TUREVALUE : CHARS_FALSEVALUE); - } - - @Override - public final void writeByte(byte value) { - writeInt(value); - } - - @Override - public final void writeChar(char value) { - writeInt(value); - } - - @Override - public final void writeShort(short value) { - writeInt(value); - } - - @Override - public final void writeInt(int value) { - writeTo(false, String.valueOf(value)); - } - - @Override - public final void writeLong(long value) { - writeTo(false, String.valueOf(value)); - } - - @Override - public final void writeFloat(float value) { - writeTo(false, String.valueOf(value)); - } - - @Override - public final void writeDouble(double value) { - writeTo(false, String.valueOf(value)); - } - - @Override - public final void wirteClassName(String clazz) { - } - - @Override - public final void writeObjectB(int fieldCount, Object obj) { - writeTo('{'); - } - - @Override - public final void writeObjectE(Object obj) { - writeTo('}'); - } - - @Override - public final void writeNull() { - writeTo('n', 'u', 'l', 'l'); - } - - @Override - public final void writeArrayB(int size) { - writeTo('['); - } - - @Override - public final void writeArrayMark() { - writeTo(','); - } - - @Override - public final void writeArrayE() { - writeTo(']'); - } - - @Override - public final void writeMapB(int size) { - writeTo('{'); - } - - @Override - public final void writeMapMark() { - writeTo(':'); - } - - @Override - public final void writeMapE() { - writeTo('}'); - } -} diff --git a/android-jdk6-redkale/src/org/redkale/net/client/HttpClient.java b/android-jdk6-redkale/src/org/redkale/net/client/HttpClient.java deleted file mode 100644 index 90ac55160..000000000 --- a/android-jdk6-redkale/src/org/redkale/net/client/HttpClient.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.net.client; - -import java.net.*; -import java.util.*; - -/** - * - * 待开发…… - * - * @see http://www.redkale.org - * @author zhangjx - */ -public final class HttpClient { - - protected Map cookies; - - protected Map headers; - - protected Map params; - - protected final HttpFactory root; - - protected final URL url; - - private String method = "GET"; - - HttpClient(HttpFactory root, URL url) { - this.root = root; - this.url = url; - } - - public HttpClient setTimeoutListener(Runnable runner) { - return this; - } - - public HttpClient getMethod() { - this.method = "GET"; - return this; - } - - public HttpClient postMethod() { - this.method = "POST"; - return this; - } - - public Map getHeaders() { - return this.headers == null ? null : new HashMap(this.headers); - } - - public HttpClient addHeader(String name, String value) { - if (this.headers == null && name != null) this.headers = new HashMap(); - this.headers.put(name, value); - return this; - } - - public HttpClient addHeader(final Map headerMap) { - if (headerMap == null || headerMap.isEmpty()) return this; - if (this.headers == null) this.headers = new HashMap(); - this.headers.putAll(headerMap); - return this; - } - - public HttpClient removeHeader(String name) { - if (this.headers == null || name == null) return this; - headers.remove(name); - return this; - } - - public Map getCookies() { - return this.cookies == null ? null : new HashMap(this.cookies); - } - - public HttpClient addCookie(final HttpCookie cookie) { - if (this.cookies == null) this.cookies = new HashMap(); - if (cookie != null) this.cookies.put(cookie.getName(), cookie); - return this; - } - - public HttpClient addCookie(final HttpCookie... httpCookies) { - if (httpCookies == null || httpCookies.length < 1) return this; - if (this.cookies == null) this.cookies = new HashMap(); - for (HttpCookie c : httpCookies) { - if (c != null) this.cookies.put(c.getName(), c); - } - return this; - } - - public HttpClient removeCookie(final String name) { - if (this.cookies != null && name != null) this.cookies.remove(name); - return this; - } - - public static void main(String[] args) throws Exception { - URL url = new URL("https://www.redkale.org"); - System.out.println(url.openConnection().getClass()); - } -} diff --git a/android-jdk6-redkale/src/org/redkale/net/client/HttpFactory.java b/android-jdk6-redkale/src/org/redkale/net/client/HttpFactory.java deleted file mode 100644 index 6eeca4e1d..000000000 --- a/android-jdk6-redkale/src/org/redkale/net/client/HttpFactory.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.net.client; - -import java.net.*; -import java.util.*; -import java.util.concurrent.*; - -/** - * 待开发…… - * - * @see http://www.redkale.org - * @author zhangjx - */ -public class HttpFactory { - - private static final HttpFactory instance = new HttpFactory(null); - - final HttpFactory parent; - - final Map defaultCookies = new ConcurrentHashMap(); - - final Map defaultHeaders = new ConcurrentHashMap(); - - private HttpFactory(HttpFactory parent) { - this.parent = parent; - } - - public HttpFactory parent() { - return this.parent; - } - - public static HttpFactory root() { - return instance; - } - - public HttpFactory createChild() { - return new HttpFactory(this); - } - - public Map getDefaultHeader() { - return new HashMap(defaultHeaders); - } - - public HttpFactory addDefaultHeader(String name, String value) { - defaultHeaders.put(name, value); - return this; - } - - public HttpFactory removeDefaultHeader(String name) { - defaultHeaders.remove(name); - return this; - } - - public HttpFactory addDefaultCookie(HttpCookie cookie) { - if (cookie != null) defaultCookies.put(cookie.getName(), cookie); - return this; - } - - public HttpFactory addDefaultCookie(HttpCookie... cookies) { - if (cookies != null) { - for (HttpCookie c : cookies) { - if (c != null) defaultCookies.put(c.getName(), c); - } - } - return this; - } - - public HttpFactory removeDefaultCookie(String name) { - defaultCookies.remove(name); - return this; - } - - public HttpClient open(URL url) { - return new HttpClient(this, url); - } -} diff --git a/android-jdk6-redkale/src/org/redkale/net/client/WebSocketClient.java b/android-jdk6-redkale/src/org/redkale/net/client/WebSocketClient.java deleted file mode 100644 index 38aa00ab4..000000000 --- a/android-jdk6-redkale/src/org/redkale/net/client/WebSocketClient.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.net.client; - -import java.io.*; -import java.net.*; -import java.util.*; -import java.util.concurrent.*; -import javax.net.ssl.*; -import org.redkale.util.*; - -/** - * 待开发…… - * - * @see http://www.redkale.org - * @author zhangjx - */ -public class WebSocketClient { - - protected final boolean ssl; - - protected final URI uri; - - protected final Map headers = new HashMap(); - - private Proxy proxy; - - private SSLContext sslContext; - - private Socket socket; - - private final Map attributes = new ConcurrentHashMap(); - - private WebSocketClient(URI uri, Map headers0) { - this.uri = uri; - this.ssl = "wss".equalsIgnoreCase(uri.getScheme()); - if (headers0 != null) this.headers.putAll(headers0); - } - - public URI getURI() { - return uri; - } - - public static WebSocketClient create(URI uri) { - return create(uri, null); - } - - public static WebSocketClient create(URI uri, Map headers) { - return new WebSocketClient(uri, headers); - } - - public WebSocketClient setSSLContext(SSLContext sslContext) { - this.sslContext = sslContext; - return this; - } - - public WebSocketClient setProxy(Proxy proxy) { - this.proxy = proxy; - return this; - } - - public WebSocketClient addHeader(String name, String value) { - this.headers.put(name, value); - return this; - } - - public int getPort() { - int port = uri.getPort(); - if (port > 0) return port; - return ssl ? 443 : 80; - } - - public void connect() throws IOException { - if (ssl) { - if (proxy == null) { - this.socket = (sslContext == null ? Utility.getDefaultSSLContext() : sslContext).getSocketFactory().createSocket(uri.getHost(), getPort()); - } else { - Socket s = new Socket(proxy); - this.socket.setSoTimeout(3000); - s.connect(new InetSocketAddress(uri.getHost(), getPort())); - this.socket = (sslContext == null ? Utility.getDefaultSSLContext() : sslContext).getSocketFactory().createSocket(s, uri.getHost(), getPort(), true); - } - } else { - this.socket = proxy == null ? new Socket() : new Socket(proxy); - this.socket.setSoTimeout(3000); - this.socket.connect(new InetSocketAddress(uri.getHost(), getPort())); - } - } - - public static void main(String[] args) throws Exception { - URI uri = new URI("ws://10.28.2.207:5050/pipes/ws/listen?test=aa"); - WebSocketClient client = WebSocketClient.create(uri); - client.connect(); - System.out.println(); - } - - public void onConnected() { - } - - public void onMessage(String text) { - } - - public void onPing(byte[] bytes) { - } - - public void onPong(byte[] bytes) { - } - - public void onMessage(byte[] bytes) { - } - - public void onFragment(String text, boolean last) { - } - - public void onFragment(byte[] bytes, boolean last) { - } - - public void onClose(int code, String reason) { - } - - /** - * 获取当前WebSocket下的属性 - *

- * @param - * @param name - * @return - */ - @SuppressWarnings("unchecked") - public final T getAttribute(String name) { - return (T) attributes.get(name); - } - - /** - * 移出当前WebSocket下的属性 - *

- * @param - * @param name - * @return - */ - public final T removeAttribute(String name) { - return (T) attributes.remove(name); - } - - /** - * 给当前WebSocket下的增加属性 - *

- * @param name - * @param value - */ - public final void setAttribute(String name, Object value) { - attributes.put(name, value); - } -} diff --git a/android-jdk6-redkale/src/org/redkale/util/AnyValue.java b/android-jdk6-redkale/src/org/redkale/util/AnyValue.java deleted file mode 100644 index 737753c38..000000000 --- a/android-jdk6-redkale/src/org/redkale/util/AnyValue.java +++ /dev/null @@ -1,446 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.util; - -import java.lang.reflect.Array; -import java.util.*; -import java.util.function.BiPredicate; - -/** - * 该类提供类似JSONObject的数据结构,主要用于读取xml配置文件和http-header存储 - * - * @see http://www.redkale.org - * @author zhangjx - */ -@SuppressWarnings("unchecked") -public abstract class AnyValue { - - /** - * 可读写的AnyValue默认实现类 - * - * @see http://www.redkale.org - * @author zhangjx - */ - @SuppressWarnings("unchecked") - public static final class DefaultAnyValue extends AnyValue { - - public static final BiPredicate EQUALS = new BiPredicate() { - @Override - public boolean test(String name1, String name2) { - return name1.equals(name2); - } - }; - - public static final BiPredicate EQUALSIGNORE = new BiPredicate() { - @Override - public boolean test(String name1, String name2) { - return name1.equalsIgnoreCase(name2); - } - }; - - private final BiPredicate predicate; - - private Entry[] stringValues = new Entry[0]; - - private Entry[] entityValues = new Entry[0]; - - public static final DefaultAnyValue create() { - return new DefaultAnyValue(); - } - - public static final DefaultAnyValue create(String name, String value) { - DefaultAnyValue conf = new DefaultAnyValue(); - conf.addValue(name, value); - return conf; - } - - public static final DefaultAnyValue create(String name, AnyValue value) { - DefaultAnyValue conf = new DefaultAnyValue(); - conf.addValue(name, value); - return conf; - } - - public DefaultAnyValue() { - this(false); - } - - public DefaultAnyValue(boolean ignoreCase) { - this.predicate = ignoreCase ? EQUALSIGNORE : EQUALS; - } - - public DefaultAnyValue(BiPredicate predicate) { - this.predicate = predicate; - } - - public DefaultAnyValue duplicate() { - DefaultAnyValue rs = new DefaultAnyValue(this.predicate); - rs.stringValues = this.stringValues; - rs.entityValues = this.entityValues; - return rs; - } - - public DefaultAnyValue addAll(final AnyValue av) { - if (av == null) return this; - if (av instanceof DefaultAnyValue) { - final DefaultAnyValue adv = (DefaultAnyValue) av; - if (adv.stringValues != null) { - for (Entry en : adv.stringValues) { - this.addValue(en.name, en.value); - } - } - if (adv.entityValues != null) { - for (Entry en : adv.entityValues) { - this.addValue(en.name, en.value); - } - } - } else { - final Entry[] strings = av.getStringEntrys(); - if (strings != null) { - for (Entry en : strings) { - this.addValue(en.name, en.value); - } - } - final Entry[] anys = av.getAnyEntrys(); - if (anys != null) { - for (Entry en : anys) { - this.addValue(en.name, en.value); - } - } - } - return this; - } - - public DefaultAnyValue setAll(final AnyValue av) { - if (av == null) return this; - if (av instanceof DefaultAnyValue) { - final DefaultAnyValue adv = (DefaultAnyValue) av; - if (adv.stringValues != null) { - for (Entry en : adv.stringValues) { - this.setValue(en.name, en.value); - } - } - if (adv.entityValues != null) { - for (Entry en : adv.entityValues) { - this.setValue(en.name, en.value); - } - } - } else { - final Entry[] strings = av.getStringEntrys(); - if (strings != null) { - for (Entry en : strings) { - this.setValue(en.name, en.value); - } - } - final Entry[] anys = av.getAnyEntrys(); - if (anys != null) { - for (Entry en : anys) { - this.setValue(en.name, en.value); - } - } - } - return this; - } - - @Override - public Entry[] getStringEntrys() { - return stringValues; - } - - @Override - public Entry[] getAnyEntrys() { - return entityValues; - } - - @Override - public String[] getNames() { - Set set = new LinkedHashSet(); - for (Entry en : this.stringValues) { - set.add(en.name); - } - for (Entry en : this.entityValues) { - set.add(en.name); - } - return set.toArray(new String[set.size()]); - } - - @Override - public String[] getValues(String... names) { - return Entry.getValues(this.predicate, String.class, this.stringValues, names); - } - - @Override - public AnyValue[] getAnyValues(String... names) { - return Entry.getValues(this.predicate, AnyValue.class, this.entityValues, names); - } - - @Override - public String toString() { - return toString(0); - } - - public DefaultAnyValue clear() { - this.stringValues = new Entry[0]; - this.entityValues = new Entry[0]; - return this; - } - - public DefaultAnyValue setValue(String name, String value) { - if (name == null) return this; - if (getValue(name) == null) { - this.addValue(name, value); - } else { - for (Entry en : this.stringValues) { - if (predicate.test(en.name, name)) { - en.value = value; - return this; - } - } - } - return this; - } - - public DefaultAnyValue setValue(String name, AnyValue value) { - if (name == null) return this; - if (getValue(name) == null) { - this.addValue(name, value); - } else { - for (Entry en : this.entityValues) { - if (predicate.test(en.name, name)) { - en.value = value; - return this; - } - } - } - return this; - } - - public DefaultAnyValue addValue(String name, String value) { - if (name == null) return this; - int len = this.stringValues.length; - Entry[] news = new Entry[len + 1]; - System.arraycopy(this.stringValues, 0, news, 0, len); - news[len] = new Entry(name, value); - this.stringValues = news; - return this; - } - - public DefaultAnyValue addValue(String name, AnyValue value) { - if (name == null || value == null) return this; - int len = this.entityValues.length; - Entry[] news = new Entry[len + 1]; - System.arraycopy(this.entityValues, 0, news, 0, len); - news[len] = new Entry(name, value); - this.entityValues = news; - return this; - } - - @Override - public AnyValue getAnyValue(String name) { - for (Entry en : this.entityValues) { - if (predicate.test(en.name, name)) { - return en.value; - } - } - return null; - } - - @Override - public String getValue(String name) { - for (Entry en : this.stringValues) { - if (predicate.test(en.name, name)) { - return en.value; - } - } - return null; - } - - @Override - public String[] getValues(String name) { - return Entry.getValues(this.predicate, String.class, this.stringValues, name); - } - - @Override - public AnyValue[] getAnyValues(String name) { - return Entry.getValues(this.predicate, AnyValue.class, this.entityValues, name); - } - - } - - public static final class Entry { - - public final String name; - - T value; - - public Entry(String name0, T value0) { - this.name = name0; - this.value = value0; - } - - public T getValue() { - return value; - } - - static T[] getValues(BiPredicate comparison, Class clazz, Entry[] entitys, String name) { - int len = 0; - for (Entry en : entitys) { - if (comparison.test(en.name, name)) { - ++len; - } - } - if (len == 0) return (T[]) Array.newInstance(clazz, len); - T[] rs = (T[]) Array.newInstance(clazz, len); - int i = 0; - for (Entry en : entitys) { - if (comparison.test(en.name, name)) { - rs[i++] = en.value; - } - } - return rs; - } - - static T[] getValues(BiPredicate comparison, Class clazz, Entry[] entitys, String... names) { - int len = 0; - for (Entry en : entitys) { - for (String name : names) { - if (comparison.test(en.name, name)) { - ++len; - break; - } - } - } - if (len == 0) return (T[]) Array.newInstance(clazz, len); - T[] rs = (T[]) Array.newInstance(clazz, len); - int i = 0; - for (Entry en : entitys) { - for (String name : names) { - if (comparison.test(en.name, name)) { - rs[i++] = en.value; - break; - } - } - } - return rs; - } - } - - public static AnyValue create() { - return new DefaultAnyValue(); - } - - protected String toString(int len) { - if (len < 0) len = 0; - char[] chars = new char[len]; - Arrays.fill(chars, ' '); - final String space = new String(chars); - StringBuilder sb = new StringBuilder(); - sb.append("{\r\n"); - for (Entry en : getStringEntrys()) { - sb.append(space).append(" '").append(en.name).append("': '").append(en.value).append("',\r\n"); - } - for (Entry en : getAnyEntrys()) { - sb.append(space).append(" '").append(en.name).append("': '").append(en.value.toString(len + 4)).append("',\r\n"); - } - sb.append(space).append('}'); - return sb.toString(); - } - - public abstract Entry[] getStringEntrys(); - - public abstract Entry[] getAnyEntrys(); - - public abstract String[] getNames(); - - public abstract String[] getValues(String name); - - public abstract String[] getValues(String... names); - - public abstract AnyValue[] getAnyValues(String name); - - public abstract AnyValue[] getAnyValues(String... names); - - public abstract AnyValue getAnyValue(String name); - - public abstract String getValue(String name); - - public boolean getBoolValue(String name) { - return Boolean.parseBoolean(getValue(name)); - } - - public boolean getBoolValue(String name, boolean defaultValue) { - String value = getValue(name); - return value == null ? defaultValue : Boolean.parseBoolean(value); - } - - public byte getByteValue(String name) { - return Byte.parseByte(getValue(name)); - } - - public byte getByteValue(String name, byte defaultValue) { - String value = getValue(name); - return value == null ? defaultValue : Byte.decode(value); - } - - public char getCharValue(String name) { - return getValue(name).charAt(0); - } - - public char getCharValue(String name, char defaultValue) { - String value = getValue(name); - return value == null || value.length() == 0 ? defaultValue : value.charAt(0); - } - - public short getShortValue(String name) { - return Short.decode(getValue(name)); - } - - public short getShortValue(String name, short defaultValue) { - String value = getValue(name); - return value == null ? defaultValue : Short.decode(value); - } - - public int getIntValue(String name) { - return Integer.decode(getValue(name)); - } - - public int getIntValue(String name, int defaultValue) { - String value = getValue(name); - return value == null ? defaultValue : Integer.decode(value); - } - - public long getLongValue(String name) { - return Long.decode(getValue(name)); - } - - public long getLongValue(String name, long defaultValue) { - String value = getValue(name); - return value == null ? defaultValue : Long.decode(value); - } - - public float getFloatValue(String name) { - return Float.parseFloat(getValue(name)); - } - - public float getFloatValue(String name, float defaultValue) { - String value = getValue(name); - return value == null ? defaultValue : Float.parseFloat(value); - } - - public double getDoubleValue(String name) { - return Double.parseDouble(getValue(name)); - } - - public double getDoubleValue(String name, double defaultValue) { - String value = getValue(name); - return value == null ? defaultValue : Double.parseDouble(value); - } - - public String getValue(String name, String defaultValue) { - String value = getValue(name); - return value == null ? defaultValue : value; - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/util/AsmMethodVisitor.java b/android-jdk6-redkale/src/org/redkale/util/AsmMethodVisitor.java deleted file mode 100644 index 41f966d98..000000000 --- a/android-jdk6-redkale/src/org/redkale/util/AsmMethodVisitor.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.util; - -import java.util.*; -import org.objectweb.asm.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public class AsmMethodVisitor { - - private final MethodVisitor visitor; - - private boolean debug = false; - - public AsmMethodVisitor setDebug(boolean d) { - debug = d; - return this; - } - - private final Map labels = new LinkedHashMap(); - - private static final String[] opcodes = new String[200]; //0 -18 - - static { - try { - for (java.lang.reflect.Field field : Opcodes.class.getFields()) { - String name = field.getName(); - if (name.startsWith("ASM")) continue; - if (name.startsWith("V1_")) continue; - if (name.startsWith("ACC_")) continue; - if (name.startsWith("T_")) continue; - if (name.startsWith("H_")) continue; - if (name.startsWith("F_")) continue; - if (field.getType() != int.class) continue; - opcodes[(int) (Integer) field.get(null)] = name; - } - } catch (Exception ex) { - throw new RuntimeException(ex); //不可能会发生 - } - } - - public AsmMethodVisitor(MethodVisitor visitor) { - //super(Opcodes.ASM5, visitor); - this.visitor = visitor; - } - - public AnnotationVisitor visitParameterAnnotation(int i, String string, boolean bln) { - AnnotationVisitor av = visitor.visitParameterAnnotation(i, string, bln); - if (debug) System.out.println("mv.visitParameterAnnotation(" + i + ", \"" + string + "\", " + bln + ");"); - return av; - } - - public AnnotationVisitor visitAnnotation(String desc, boolean flag) { - AnnotationVisitor av = visitor.visitAnnotation(desc, flag); - if (debug) System.out.println("mv.visitAnnotation(\"" + desc + "\", " + flag + ");"); - return av; - } - - public void visitParameter(String name, int access) { - visitor.visitParameter(name, access); - if (debug) System.out.println("mv.visitParameter(" + name + ", " + access + ");"); - } - - public void visitVarInsn(int opcode, int var) { - visitor.visitVarInsn(opcode, var); - if (debug) System.out.println("mv.visitVarInsn(" + opcodes[opcode] + ", " + var + ");"); - } - - public void visitJumpInsn(int opcode, Label var) { //调用次方法的 ClassWriter 必须由 COMPUTE_FRAMES 构建 - visitor.visitJumpInsn(opcode, var); - if (debug) { - Integer index = labels.get(var); - if (index == null) { - index = labels.size(); - labels.put(var, index); - System.out.println("Label l" + index + " = new Label();"); - } - System.out.println("mv.visitJumpInsn(" + opcodes[opcode] + ", l" + index + ");"); - } - } - - public void visitCode() { - visitor.visitCode(); - if (debug) System.out.println("mv.visitCode();"); - } - - public void visitLabel(Label var) { - visitor.visitLabel(var); - if (debug) { - Integer index = labels.get(var); - if (index == null) { - index = labels.size(); - labels.put(var, index); - System.out.println("Label l" + index + " = new Label();"); - } - System.out.println("mv.visitLabel(l" + index + ");"); - } - } - - public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { - visitor.visitMethodInsn(opcode, owner, name, desc, itf); - if (debug) System.out.println("mv.visitMethodInsn(" + opcodes[opcode] + ", \"" + owner + "\", \"" + name + "\", \"" + desc + "\", " + itf + ");"); - } - - public void visitFieldInsn(int opcode, String owner, String name, String desc) { - visitor.visitFieldInsn(opcode, owner, name, desc); - if (debug) System.out.println("mv.visitFieldInsn(" + opcodes[opcode] + ", \"" + owner + "\", \"" + name + "\", \"" + desc + "\");"); - } - - public void visitTypeInsn(int opcode, String type) { - visitor.visitTypeInsn(opcode, type); - if (debug) System.out.println("mv.visitTypeInsn(" + opcodes[opcode] + ", \"" + type + "\");"); - } - - public void visitInsn(int opcode) { - visitor.visitInsn(opcode); - if (debug) System.out.println("mv.visitInsn(" + opcodes[opcode] + ");"); - } - - public void visitIntInsn(int opcode, int value) { - visitor.visitIntInsn(opcode, value); - if (debug) System.out.println("mv.visitIntInsn(" + opcodes[opcode] + ", " + value + ");"); - } - - public void visitIincInsn(int opcode, int value) { - visitor.visitIincInsn(opcode, value); - if (debug) System.out.println("mv.visitIincInsn(" + opcode + ", " + value + ");"); - } - - public void visitLdcInsn(Object o) { - visitor.visitLdcInsn(o); - if (debug) System.out.println("mv.visitLdcInsn(" + o + ");"); - } - - public void visitMaxs(int maxStack, int maxLocals) { - visitor.visitMaxs(maxStack, maxLocals); - if (debug) System.out.println("mv.visitMaxs(" + maxStack + ", " + maxLocals + ");"); - } - - public void visitEnd() { - visitor.visitEnd(); - if (debug) System.out.println("mv.visitEnd();\r\n\r\n\r\n"); - } -} diff --git a/android-jdk6-redkale/src/org/redkale/util/Attribute.java b/android-jdk6-redkale/src/org/redkale/util/Attribute.java deleted file mode 100644 index e1054bc1b..000000000 --- a/android-jdk6-redkale/src/org/redkale/util/Attribute.java +++ /dev/null @@ -1,375 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.util; - -import java.lang.reflect.*; -import static org.objectweb.asm.Opcodes.*; -import org.objectweb.asm.Type; - -/** - * 该类功能是动态映射一个Data类中成员对应的getter、setter方法; 代替低效的反射实现方式。 - * 映射Field时,field必须满足以下条件之一: - * 1、field属性是public且非final - * 2、至少存在对应的getter、setter方法中的一个 - * 当不存在getter方法时,get操作规定返回null - * 当不存在setter方法时,set操作为空方法 - * - * @see http://www.redkale.org - * @author zhangjx - * @param - * @param - */ -public interface Attribute { - - public Class type(); - - public Class declaringClass(); - - public String field(); - - public F get(T obj); - - public void set(T obj, F value); - - public static abstract class Attributes { - - /** - * 根据一个Field生成 Attribute 对象。 - * - * @param - * @param - * @param field - * @return - */ - public static Attribute create(final Field field) { - return create((Class) field.getDeclaringClass(), field.getName(), field, null, null); - } - - /** - * 根据一个Field和field的别名生成 Attribute 对象。 - * - * @param - * @param - * @param fieldname 别名 - * @param field - * @return - */ - public static Attribute create(String fieldname, final Field field) { - return create((Class) field.getDeclaringClass(), fieldname, field, null, null); - } - - /** - * 根据一个Class和field名生成 Attribute 对象。 - * - * @param - * @param - * @param clazz - * @param fieldname 字段名, 如果该字段不存在则抛异常 - * @return - */ - public static Attribute create(Class clazz, final String fieldname) { - try { - return create(clazz, fieldname, clazz.getDeclaredField(fieldname), null, null); - } catch (NoSuchFieldException ex) { - throw new RuntimeException(ex); - } catch (SecurityException ex) { - throw new RuntimeException(ex); - } - } - - public static Attribute create(Class clazz, final java.lang.reflect.Field field) { - return create(clazz, field.getName(), field); - } - - public static Attribute create(Class clazz, final String fieldname, final java.lang.reflect.Field field) { - return create(clazz, fieldname, field, null, null); - } - - /** - * getter、setter不能全为null - * - * @param - * @param - * @param getter - * @param setter - * @return - */ - public static Attribute create(final Method getter, final Method setter) { - return create((Class) (getter == null ? setter.getDeclaringClass() : getter.getDeclaringClass()), null, null, getter, setter); - } - - /** - * getter、setter不能全为null - * - * @param - * @param - * @param clazz - * @param getter - * @param setter - * @return - */ - public static Attribute create(Class clazz, final Method getter, final Method setter) { - return create(clazz, null, null, getter, setter); - } - - /** - * getter、setter不能全为null - * - * @param - * @param - * @param clazz - * @param fieldalias - * @param getter - * @param setter - * @return - */ - public static Attribute create(Class clazz, final String fieldalias, final Method getter, final Method setter) { - return create(clazz, fieldalias, null, getter, setter); - } - - /** - * field、getter、setter不能全为null - * - * @param - * @param - * @param clazz - * @param fieldalias0 - * @param field0 - * @param getter0 - * @param setter0 - * @return - */ - @SuppressWarnings("unchecked") - public static Attribute create(final Class clazz, String fieldalias0, final Field field0, Method getter0, Method setter0) { - if (fieldalias0 != null && fieldalias0.isEmpty()) fieldalias0 = null; - int mod = field0 == null ? Modifier.STATIC : field0.getModifiers(); - if (field0 != null && !Modifier.isStatic(mod) && !Modifier.isPublic(mod)) { - Class t = field0.getType(); - char[] fs = field0.getName().toCharArray(); - fs[0] = Character.toUpperCase(fs[0]); - String mn = new String(fs); - if (getter0 == null) { - String prefix = t == boolean.class || t == Boolean.class ? "is" : "get"; - try { - getter0 = clazz.getMethod(prefix + mn); - } catch (Exception ex) { - } - } - if (setter0 == null) { - try { - setter0 = clazz.getMethod("set" + mn, field0.getType()); - } catch (Exception ex) { - } - } - } - final Field field = field0 == null ? null : (!Modifier.isPublic(mod) || Modifier.isStatic(mod) ? null : field0); - final java.lang.reflect.Method getter = getter0; - final java.lang.reflect.Method setter = setter0; - if (fieldalias0 == null) { - if (field0 != null) { - fieldalias0 = field0.getName(); - } else { - String s; - if (getter0 != null) { - s = getter0.getName().substring(getter0.getName().startsWith("is") ? 2 : 3); - } else { - s = setter0.getName().substring(3); - } - char[] d = s.toCharArray(); - if (d.length < 2 || Character.isLowerCase(d[1])) { - d[0] = Character.toLowerCase(d[0]); - } - fieldalias0 = new String(d); - } - } - if (getter == null && setter == null && field == null) { - throw new RuntimeException("[" + clazz + "]have no public field or setter or getter"); - } - final String fieldname = fieldalias0; - Class column; - if (field != null) { // public field - column = field.getType(); - } else if (getter != null) { - column = getter.getReturnType(); - } else { // setter != null - column = setter.getParameterTypes()[0]; - } - final Class pcolumn = column; - if (column.isPrimitive()) column = Array.get(Array.newInstance(column, 1), 0).getClass(); - final String supDynName = Attribute.class.getName().replace('.', '/'); - final String interName = clazz.getName().replace('.', '/'); - final String columnName = column.getName().replace('.', '/'); - final String interDesc = Type.getDescriptor(clazz); - final String columnDesc = Type.getDescriptor(column); - - ClassLoader loader = Attribute.class.getClassLoader(); - String newDynName = supDynName + "_Dyn_" + clazz.getSimpleName() + "_" - + fieldname.substring(fieldname.indexOf('.') + 1) + "_" + pcolumn.getSimpleName().replace("[]", "Array"); - if (String.class.getClassLoader() != clazz.getClassLoader()) { - loader = clazz.getClassLoader(); - newDynName = interName + "_Dyn" + Attribute.class.getSimpleName() + "_" - + fieldname.substring(fieldname.indexOf('.') + 1) + "_" + pcolumn.getSimpleName().replace("[]", "Array"); - } - try { - return (Attribute) Class.forName(newDynName.replace('/', '.')).newInstance(); - } catch (Throwable ex) { - } - //--------------------------------------------------- - final org.objectweb.asm.ClassWriter cw = new org.objectweb.asm.ClassWriter(0); - org.objectweb.asm.MethodVisitor mv; - - cw.visit(V1_7, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, newDynName, "Ljava/lang/Object;L" + supDynName + "<" + interDesc + columnDesc + ">;", "java/lang/Object", new String[]{supDynName}); - - { //构造方法 - mv = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null); - mv.visitVarInsn(ALOAD, 0); - mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V", false); - mv.visitInsn(RETURN); - mv.visitMaxs(1, 1); - mv.visitEnd(); - } - - { //field 方法 - mv = cw.visitMethod(ACC_PUBLIC, "field", "()Ljava/lang/String;", null, null); - mv.visitLdcInsn(fieldname); - mv.visitInsn(ARETURN); - mv.visitMaxs(1, 1); - mv.visitEnd(); - } - { //type 方法 - mv = cw.visitMethod(ACC_PUBLIC, "type", "()Ljava/lang/Class;", null, null); - if (pcolumn == boolean.class) { - mv.visitFieldInsn(GETSTATIC, "java/lang/Boolean", "TYPE", "Ljava/lang/Class;"); - } else if (pcolumn == byte.class) { - mv.visitFieldInsn(GETSTATIC, "java/lang/Byte", "TYPE", "Ljava/lang/Class;"); - } else if (pcolumn == char.class) { - mv.visitFieldInsn(GETSTATIC, "java/lang/Character", "TYPE", "Ljava/lang/Class;"); - } else if (pcolumn == short.class) { - mv.visitFieldInsn(GETSTATIC, "java/lang/Short", "TYPE", "Ljava/lang/Class;"); - } else if (pcolumn == int.class) { - mv.visitFieldInsn(GETSTATIC, "java/lang/Integer", "TYPE", "Ljava/lang/Class;"); - } else if (pcolumn == float.class) { - mv.visitFieldInsn(GETSTATIC, "java/lang/Float", "TYPE", "Ljava/lang/Class;"); - } else if (pcolumn == long.class) { - mv.visitFieldInsn(GETSTATIC, "java/lang/Long", "TYPE", "Ljava/lang/Class;"); - } else if (pcolumn == double.class) { - mv.visitFieldInsn(GETSTATIC, "java/lang/Double", "TYPE", "Ljava/lang/Class;"); - } else { - mv.visitLdcInsn(Type.getType(pcolumn)); - } - mv.visitInsn(ARETURN); - mv.visitMaxs(1, 1); - mv.visitEnd(); - } - { //declaringClass 方法 - mv = cw.visitMethod(ACC_PUBLIC, "declaringClass", "()Ljava/lang/Class;", null, null); - mv.visitLdcInsn(Type.getType(clazz)); - mv.visitInsn(ARETURN); - mv.visitMaxs(1, 1); - mv.visitEnd(); - } - { //get 方法 - mv = cw.visitMethod(ACC_PUBLIC, "get", "(" + interDesc + ")" + columnDesc, null, null); - int m = 1; - if (getter == null) { - if (field == null) { - mv.visitInsn(ACONST_NULL); - } else { //public field - mv.visitVarInsn(ALOAD, 1); - mv.visitFieldInsn(GETFIELD, interName, field.getName(), Type.getDescriptor(pcolumn)); - if (pcolumn != column) { - mv.visitMethodInsn(INVOKESTATIC, columnName, "valueOf", "(" + Type.getDescriptor(pcolumn) + ")" + columnDesc, false); - m = 2; - } - } - } else { - mv.visitVarInsn(ALOAD, 1); - mv.visitMethodInsn(INVOKEVIRTUAL, interName, getter.getName(), Type.getMethodDescriptor(getter), false); - if (pcolumn != column) { - mv.visitMethodInsn(INVOKESTATIC, columnName, "valueOf", "(" + Type.getDescriptor(pcolumn) + ")" + columnDesc, false); - m = 2; - } - } - mv.visitInsn(ARETURN); - mv.visitMaxs(m, 2); - mv.visitEnd(); - } - { //set 方法 - mv = cw.visitMethod(ACC_PUBLIC, "set", "(" + interDesc + columnDesc + ")V", null, null); - int m = 2; - if (setter == null) { - if (field == null || Modifier.isFinal(field.getModifiers())) { - m = 0; - } else { //public field - mv.visitVarInsn(ALOAD, 1); - mv.visitVarInsn(ALOAD, 2); - if (pcolumn != column) { - try { - java.lang.reflect.Method pm = column.getMethod(pcolumn.getSimpleName() + "Value"); - mv.visitMethodInsn(INVOKEVIRTUAL, columnName, pm.getName(), Type.getMethodDescriptor(pm), false); - m = 3; - } catch (Exception ex) { - throw new RuntimeException(ex); //不可能会发生 - } - } - mv.visitFieldInsn(PUTFIELD, interName, field.getName(), Type.getDescriptor(pcolumn)); - } - } else { - mv.visitVarInsn(ALOAD, 1); - mv.visitVarInsn(ALOAD, 2); - if (pcolumn != column) { - try { - java.lang.reflect.Method pm = column.getMethod(pcolumn.getSimpleName() + "Value"); - mv.visitMethodInsn(INVOKEVIRTUAL, columnName, pm.getName(), Type.getMethodDescriptor(pm), false); - m = 3; - } catch (Exception ex) { - throw new RuntimeException(ex); //不可能会发生 - } - } - mv.visitMethodInsn(INVOKEVIRTUAL, interName, setter.getName(), Type.getMethodDescriptor(setter), false); - } - mv.visitInsn(RETURN); - mv.visitMaxs(m, 3); - mv.visitEnd(); - } - { //虚拟get - mv = cw.visitMethod(ACC_PUBLIC + ACC_BRIDGE + ACC_SYNTHETIC, "get", "(Ljava/lang/Object;)Ljava/lang/Object;", null, null); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ALOAD, 1); - mv.visitTypeInsn(CHECKCAST, interName); - mv.visitMethodInsn(INVOKEVIRTUAL, newDynName, "get", "(" + interDesc + ")" + columnDesc, false); - mv.visitInsn(ARETURN); - mv.visitMaxs(2, 2); - mv.visitEnd(); - } - {//虚拟set - mv = cw.visitMethod(ACC_PUBLIC + ACC_BRIDGE + ACC_SYNTHETIC, "set", "(Ljava/lang/Object;Ljava/lang/Object;)V", null, null); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ALOAD, 1); - mv.visitTypeInsn(CHECKCAST, interName); - mv.visitVarInsn(ALOAD, 2); - mv.visitTypeInsn(CHECKCAST, columnName); - mv.visitMethodInsn(INVOKEVIRTUAL, newDynName, "set", "(" + interDesc + columnDesc + ")V", false); - mv.visitInsn(RETURN); - mv.visitMaxs(3, 3); - mv.visitEnd(); - } - cw.visitEnd(); - - byte[] bytes = cw.toByteArray(); - Class creatorClazz = (Class) new ClassLoader(loader) { - public final Class loadClass(String name, byte[] b) { - return defineClass(name, b, 0, b.length); - } - }.loadClass(newDynName.replace('/', '.'), bytes); - try { - return creatorClazz.newInstance(); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - } -} diff --git a/android-jdk6-redkale/src/org/redkale/util/AutoLoad.java b/android-jdk6-redkale/src/org/redkale/util/AutoLoad.java deleted file mode 100644 index cb693927d..000000000 --- a/android-jdk6-redkale/src/org/redkale/util/AutoLoad.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.util; - -import java.lang.annotation.*; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * 自动加载。 使用场景: - * 1、被标记为@AutoLoad(false)的Service类不会被自动加载 - * 2、被标记为@AutoLoad(false)的Servlet类不会被自动加载 - * 3、被标记为@AutoLoad且同时被标记为@javax.persistence.Cacheable的Entity类在被DataSource初始化时需要将Entity类对应的表数据全量加载进缓存中。 - * - * @see http://www.redkale.org - * @author zhangjx - */ -@Inherited -@Documented -@Target({TYPE}) -@Retention(RUNTIME) -public @interface AutoLoad { - - boolean value() default true; -} diff --git a/android-jdk6-redkale/src/org/redkale/util/ByteArray.java b/android-jdk6-redkale/src/org/redkale/util/ByteArray.java deleted file mode 100644 index fcbd774aa..000000000 --- a/android-jdk6-redkale/src/org/redkale/util/ByteArray.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.util; - -import java.nio.*; -import java.nio.charset.*; - -/** - * 简单的byte[]操作类。 - * - * @see http://www.redkale.org - * @author zhangjx - */ -public final class ByteArray { - - private byte[] content; - - private int count; - - public ByteArray() { - this(1024); - } - - public ByteArray(int size) { - content = new byte[Math.max(128, size)]; - } - - public void clear() { - this.count = 0; - } - - public int find(byte value) { - return find(0, value); - } - - public boolean equal(final byte[] bytes) { - if (bytes == null || count != bytes.length) return false; - for (int i = 0; i < count; i++) { - if (content[i] != bytes[i]) return false; - } - return true; - } - - public boolean isEmpty() { - return count == 0; - } - - public int count() { - return count; - } - - public void write(byte[] buf) { - System.arraycopy(this.content, 0, buf, 0, count); - } - - public byte[] directBytes() { - return content; - } - - public int find(int offset, char value) { - return find(offset, (byte) value); - } - - public int find(int offset, byte value) { - return find(offset, -1, value); - } - - public int find(int offset, int limit, char value) { - return find(offset, limit, (byte) value); - } - - public int find(int offset, int limit, byte value) { - byte[] bytes = this.content; - int end = limit > 0 ? limit : count; - for (int i = offset; i < end; i++) { - if (bytes[i] == value) return i; - } - return -1; - } - - public void removeLastByte() { - if (count > 0) count--; - } - - public void addInt(int value) { - add((byte) (value >> 24 & 0xFF), (byte) (value >> 16 & 0xFF), (byte) (value >> 8 & 0xFF), (byte) (value & 0xFF)); - } - - public void add(byte value) { - if (count >= content.length - 1) { - byte[] ns = new byte[content.length + 8]; - System.arraycopy(content, 0, ns, 0, count); - this.content = ns; - } - content[count++] = value; - } - - public void add(byte... values) { - if (count >= content.length - values.length) { - byte[] ns = new byte[content.length + values.length]; - System.arraycopy(content, 0, ns, 0, count); - this.content = ns; - } - System.arraycopy(content, count, values, 0, values.length); - count += values.length; - } - - public void add(ByteBuffer buffer, int len) { - if (len < 1) return; - if (count >= content.length - len) { - byte[] ns = new byte[content.length + len]; - System.arraycopy(content, 0, ns, 0, count); - this.content = ns; - } - buffer.get(content, count, len); - count += len; - } - - @Override - public String toString() { - return new String(content, 0, count); - } - - public String toString(final Charset charset) { - return toString(0, count, charset); - } - - public String toString(final int offset, int len, final Charset charset) { - if (charset == null) return new String(Utility.decodeUTF8(content, offset, len)); - return new String(content, offset, len, charset); - } - - public String toDecodeString(final int offset, int len, final Charset charset) { - int index = offset; - for (int i = offset; i < (offset + len); i++) { - switch (content[i]) { - case '+': - content[index] = ' '; - break; - case '%': - content[index] = (byte) ((hexBit(content[++i]) * 16 + hexBit(content[++i]))); - break; - default: - content[index] = content[i]; - break; - } - index++; - } - for (int i = index + 1; i < (offset + len); i++) { - content[i] = ' '; - } - len = index - offset; - if (charset == null) return new String(Utility.decodeUTF8(content, offset, len)); - return new String(content, offset, len, charset); - } - - private static int hexBit(byte b) { - if ('0' <= b && '9' >= b) return b - '0'; - if ('a' <= b && 'z' >= b) return b - 'a' + 10; - if ('A' <= b && 'Z' >= b) return b - 'A' + 10; - return b; - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/util/Creator.java b/android-jdk6-redkale/src/org/redkale/util/Creator.java deleted file mode 100644 index 523ce702f..000000000 --- a/android-jdk6-redkale/src/org/redkale/util/Creator.java +++ /dev/null @@ -1,296 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.util; - -import java.beans.*; -import java.io.*; -import java.lang.annotation.*; -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.RUNTIME; -import java.lang.reflect.*; -import java.net.*; -import java.util.*; - -import org.objectweb.asm.*; -import static org.objectweb.asm.Opcodes.*; -import org.objectweb.asm.Type; - -/** - * 实现一个类的构造方法。 代替低效的反射实现方式。 不支持数组类。 - * 常见的无参数的构造函数类都可以自动生成Creator, 对应自定义的类可以提供一个静态构建Creator方法。 - * - * 例如: - * public class Record { - * - * private final int id; - * - * private String name; - * - * Record(int id, String name) { - * this.id = id; - * this.name = name; - * } - * - * private static Creator createCreator() { - * return new Creator() { - * @Override - * @ConstructorParameters({"id", "name"}) - * public Record create(Object... params) { - * return new Record((Integer) params[0], (String) params[1]); - * } - * }; - * } - * } - * - * 或者: - * public class Record { - * - * private final int id; - * - * private String name; - * - * @ConstructorProperties({"id", "name"}) - * public Record(int id, String name) { - * this.id = id; - * this.name = name; - * } - * } - * - * @see http://www.redkale.org - * @author zhangjx - * @param - */ -public interface Creator { - - @Documented - @Target({METHOD}) - @Retention(RUNTIME) - public static @interface ConstructorParameters { - - String[] value(); - } - - public T create(Object... params); - - public abstract class Creators { - - @SuppressWarnings("unchecked") - public static Creator create(Class clazz) { - if (clazz.isAssignableFrom(ArrayList.class)) { - clazz = (Class) ArrayList.class; - } else if (clazz.isAssignableFrom(HashMap.class)) { - clazz = (Class) HashMap.class; - } else if (clazz.isAssignableFrom(HashSet.class)) { - clazz = (Class) HashSet.class; - } - if (clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers())) { - throw new RuntimeException("[" + clazz + "] is a interface or abstract class, cannot create it's Creator."); - } - for (final Method method : clazz.getDeclaredMethods()) { - if (!Modifier.isStatic(method.getModifiers())) continue; - if (method.getParameterTypes().length != 0) continue; - if (method.getReturnType() != Creator.class) continue; - try { - method.setAccessible(true); - return (Creator) method.invoke(null); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - final String supDynName = Creator.class.getName().replace('.', '/'); - final String interName = clazz.getName().replace('.', '/'); - final String interDesc = Type.getDescriptor(clazz); - ClassLoader loader = Creator.class.getClassLoader(); - String newDynName = supDynName + "_" + clazz.getSimpleName() + "_" + (System.currentTimeMillis() % 10000); - if (String.class.getClassLoader() != clazz.getClassLoader()) { - loader = clazz.getClassLoader(); - newDynName = interName + "_Dyn" + Creator.class.getSimpleName(); - } - try { - return (Creator) Class.forName(newDynName.replace('/', '.')).newInstance(); - } catch (Exception ex) { - } - Constructor constructor0 = null; - for (Constructor c : clazz.getConstructors()) { - if (c.getParameterTypes().length == 0) { //为了兼容android 而不使用 getParameterCount() - constructor0 = c; - break; - } - } - if (constructor0 == null) { - for (Constructor c : clazz.getDeclaredConstructors()) { - if (Modifier.isPrivate(c.getModifiers())) continue; - if (c.getAnnotation(ConstructorProperties.class) != null) { - constructor0 = c; - break; - } - } - } - final Constructor constructor = constructor0; - if (constructor == null) throw new RuntimeException("[" + clazz + "] have no public or java.beans.ConstructorProperties-Annotation constructor."); - //------------------------------------------------------------- - ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); - FieldVisitor fv; - MethodVisitor mv; - AnnotationVisitor av0; - cw.visit(V1_7, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, newDynName, "Ljava/lang/Object;L" + supDynName + "<" + interDesc + ">;", "java/lang/Object", new String[]{supDynName}); - - {//构造方法 - mv = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null); - mv.visitVarInsn(ALOAD, 0); - mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V", false); - mv.visitInsn(RETURN); - mv.visitMaxs(1, 1); - mv.visitEnd(); - } - {//create 方法 - mv = cw.visitMethod(ACC_PUBLIC + ACC_VARARGS, "create", "([Ljava/lang/Object;)L" + interName + ";", null, null); - ConstructorProperties cps = constructor.getAnnotation(ConstructorProperties.class); - final String[] cparams = cps == null ? null : cps.value(); - if (cparams != null) { - av0 = mv.visitAnnotation(Type.getDescriptor(ConstructorParameters.class), true); - AnnotationVisitor av1 = av0.visitArray("value"); - for (String n : cps.value()) { - av1.visit(null, n); - } - av1.visitEnd(); - av0.visitEnd(); - } - final Class[] paramTypes = constructor.getParameterTypes(); - final int[] iconsts = {ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5}; - { //有Primitive数据类型且值为null的参数需要赋默认值 - for (int i = 0; i < paramTypes.length; i++) { - final Class pt = paramTypes[i]; - if (!pt.isPrimitive()) continue; - mv.visitVarInsn(ALOAD, 1); - if (i < 6) { - mv.visitInsn(iconsts[i]); - } else { - mv.visitIntInsn(BIPUSH, i); - } - mv.visitInsn(AALOAD); - Label lab = new Label(); - mv.visitJumpInsn(IFNONNULL, lab); - mv.visitVarInsn(ALOAD, 1); - if (i < 6) { - mv.visitInsn(iconsts[i]); - } else { - mv.visitIntInsn(BIPUSH, i); - } - if (pt == int.class) { - mv.visitInsn(ICONST_0); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false); - } else if (pt == long.class) { - mv.visitInsn(LCONST_0); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;", false); - } else if (pt == boolean.class) { - mv.visitFieldInsn(GETSTATIC, "java/lang/Boolean", "FALSE", "Ljava/lang/Boolean;"); - } else if (pt == short.class) { - mv.visitInsn(ICONST_0); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;", false); - } else if (pt == float.class) { - mv.visitInsn(FCONST_0); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;", false); - } else if (pt == byte.class) { - mv.visitInsn(ICONST_0); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;", false); - } else if (pt == double.class) { - mv.visitInsn(DCONST_0); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;", false); - } else if (pt == char.class) { - mv.visitInsn(ICONST_0); - mv.visitMethodInsn(INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;", false); - } - mv.visitInsn(AASTORE); - mv.visitLabel(lab); - } - } - mv.visitTypeInsn(NEW, interName); - mv.visitInsn(DUP); - //--------------------------------------- - { - for (int i = 0; i < paramTypes.length; i++) { - mv.visitVarInsn(ALOAD, 1); - if (i < 6) { - mv.visitInsn(iconsts[i]); - } else { - mv.visitIntInsn(BIPUSH, i); - } - mv.visitInsn(AALOAD); - final Class ct = paramTypes[i]; - if (ct.isPrimitive()) { - final Class bigct = Array.get(Array.newInstance(ct, 1), 0).getClass(); - mv.visitTypeInsn(CHECKCAST, bigct.getName().replace('.', '/')); - try { - Method pm = bigct.getMethod(ct.getSimpleName() + "Value"); - mv.visitMethodInsn(INVOKEVIRTUAL, bigct.getName().replace('.', '/'), pm.getName(), Type.getMethodDescriptor(pm), false); - } catch (Exception ex) { - throw new RuntimeException(ex); //不可能会发生 - } - } else { - mv.visitTypeInsn(CHECKCAST, ct.getName().replace('.', '/')); - } - } - } - //--------------------------------------- - mv.visitMethodInsn(INVOKESPECIAL, interName, "", Type.getConstructorDescriptor(constructor), false); - mv.visitInsn(ARETURN); - mv.visitMaxs((paramTypes.length > 0 ? (paramTypes.length + 3) : 2), 2); - mv.visitEnd(); - } - { //虚拟 create 方法 - mv = cw.visitMethod(ACC_PUBLIC + ACC_BRIDGE + ACC_VARARGS + ACC_SYNTHETIC, "create", "([Ljava/lang/Object;)Ljava/lang/Object;", null, null); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ALOAD, 1); - mv.visitMethodInsn(INVOKEVIRTUAL, newDynName, "create", "([Ljava/lang/Object;)" + interDesc, false); - mv.visitInsn(ARETURN); - mv.visitMaxs(2, 2); - mv.visitEnd(); - } - cw.visitEnd(); - final byte[] bytes = cw.toByteArray(); - Class resultClazz = null; - if (loader instanceof URLClassLoader) { - try { - final URLClassLoader urlLoader = (URLClassLoader) loader; - final URL url = new URL("memclass", "localhost", -1, "/" + newDynName.replace('/', '.') + "/", new URLStreamHandler() { - @Override - protected URLConnection openConnection(URL u) throws IOException { - return new URLConnection(u) { - @Override - public void connect() throws IOException { - } - - @Override - public InputStream getInputStream() throws IOException { - return new ByteArrayInputStream(bytes); - } - }; - } - }); - Method addURLMethod = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); - addURLMethod.setAccessible(true); - addURLMethod.invoke(urlLoader, url); - resultClazz = urlLoader.loadClass(newDynName.replace('/', '.')); - } catch (Throwable t) { //异常无需理会, 使用下一种loader方式 - t.printStackTrace(); - } - } - try { - if (resultClazz == null) { - if (!Modifier.isPublic(constructor.getModifiers())) throw new RuntimeException("[" + clazz + "] have no public or java.beans.ConstructorProperties-Annotation constructor."); - resultClazz = new ClassLoader(loader) { - public final Class loadClass(String name, byte[] b) { - return defineClass(name, b, 0, b.length); - } - }.loadClass(newDynName.replace('/', '.'), bytes); - } - return (Creator) resultClazz.newInstance(); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - } -} diff --git a/android-jdk6-redkale/src/org/redkale/util/DLong.java b/android-jdk6-redkale/src/org/redkale/util/DLong.java deleted file mode 100644 index 7cf402dc8..000000000 --- a/android-jdk6-redkale/src/org/redkale/util/DLong.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.util; - -import java.nio.*; -import java.util.*; - -/** - * 16bytes数据结构 - * 注意: 为了提高性能, DLong中的bytes是直接返回, 不得对bytes的内容进行修改。 - * - * @see http://www.redkale.org - * @author zhangjx - */ -public final class DLong extends Number implements Comparable { - - public static final DLong ZERO = new DLong(new byte[16]); - - protected final byte[] bytes; - - protected DLong(long v1, long v2) { //暂时不用 - this.bytes = new byte[]{(byte) (v1 >> 56), (byte) (v1 >> 48), (byte) (v1 >> 40), (byte) (v1 >> 32), - (byte) (v1 >> 24), (byte) (v1 >> 16), (byte) (v1 >> 8), (byte) v1, (byte) (v2 >> 56), (byte) (v2 >> 48), (byte) (v2 >> 40), (byte) (v2 >> 32), - (byte) (v2 >> 24), (byte) (v2 >> 16), (byte) (v2 >> 8), (byte) v2}; - } - - protected DLong(byte[] bytes) { - if (bytes == null || bytes.length != 16) throw new NumberFormatException("Not 16 length bytes"); - this.bytes = bytes; - } - - public byte[] getBytes() { - return Arrays.copyOf(bytes, bytes.length); - } - - public byte[] directBytes() { - return bytes; - } - - public static DLong create(byte[] bytes) { - if (ZERO.equals(bytes)) return ZERO; - return new DLong(bytes); - } - - public static DLong read(ByteBuffer buffer) { - byte[] bs = new byte[16]; - buffer.get(bs); - if (ZERO.equals(bs)) return ZERO; - return new DLong(bs); - } - - public static ByteBuffer write(ByteBuffer buffer, DLong value) { - buffer.put(value.bytes); - return buffer; - } - - public boolean equals(byte[] bytes) { - return Arrays.equals(this.bytes, bytes); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - final DLong other = (DLong) obj; - return Arrays.equals(this.bytes, other.bytes); - } - - @Override - public int hashCode() { - return Arrays.hashCode(bytes); - } - - @Override - public String toString() { - if (this == ZERO) return "0"; - return new String(Utility.binToHex(bytes)); - } - - @Override - public int intValue() { - return ((bytes[12] & 0xff) << 24) | ((bytes[113] & 0xff) << 16) | ((bytes[14] & 0xff) << 8) | (bytes[15] & 0xff); - } - - @Override - public long longValue() { - return ((((long) bytes[8] & 0xff) << 56) - | (((long) bytes[9] & 0xff) << 48) - | (((long) bytes[10] & 0xff) << 40) - | (((long) bytes[11] & 0xff) << 32) - | (((long) bytes[12] & 0xff) << 24) - | (((long) bytes[13] & 0xff) << 16) - | (((long) bytes[14] & 0xff) << 8) - | (((long) bytes[15] & 0xff))); - } - - @Override - public float floatValue() { - return (float) longValue(); - } - - @Override - public double doubleValue() { - return (double) longValue(); - } - - @Override - public int compareTo(DLong o) { - if (o == null) return 1; - for (int i = 0; i < bytes.length; i++) { - if (this.bytes[i] != o.bytes[i]) return this.bytes[i] - o.bytes[i]; - } - return 0; - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/util/Ignore.java b/android-jdk6-redkale/src/org/redkale/util/Ignore.java deleted file mode 100644 index 313952b45..000000000 --- a/android-jdk6-redkale/src/org/redkale/util/Ignore.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.util; - -import java.lang.annotation.*; -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * 用于忽略字段、方法或类。使用场景: - * 1、convert功能中被标记为@Ignore的字段或方法会被忽略 - * 2、FilterBean中的被标记为@Ignore的字段会被忽略 - * 3、被标记为@Ignore的Service类不会被自动加载 - * 4、被标记为@Ignore的Servlet类不会被自动加载 - * - * @see http://www.redkale.org - * @author zhangjx - */ -@Inherited -@Documented -@Target({TYPE, FIELD, METHOD}) -@Retention(RUNTIME) -public @interface Ignore { - -} diff --git a/android-jdk6-redkale/src/org/redkale/util/LogLevel.java b/android-jdk6-redkale/src/org/redkale/util/LogLevel.java deleted file mode 100644 index 408ee1414..000000000 --- a/android-jdk6-redkale/src/org/redkale/util/LogLevel.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.util; - -import java.lang.annotation.*; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * 被标记的日志级别以上的才会被记录 - * - * @see http://www.redkale.org - * @author zhangjx - */ -@Inherited -@Documented -@Target({TYPE}) -@Retention(RUNTIME) -public @interface LogLevel { - - String value(); -} diff --git a/android-jdk6-redkale/src/org/redkale/util/Nameable.java b/android-jdk6-redkale/src/org/redkale/util/Nameable.java deleted file mode 100644 index 02e6c7821..000000000 --- a/android-jdk6-redkale/src/org/redkale/util/Nameable.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.util; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public interface Nameable { - - String name(); -} diff --git a/android-jdk6-redkale/src/org/redkale/util/ObjectPool.java b/android-jdk6-redkale/src/org/redkale/util/ObjectPool.java deleted file mode 100644 index 77a8b260d..000000000 --- a/android-jdk6-redkale/src/org/redkale/util/ObjectPool.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.util; - -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; -import java.util.function.*; -import java.util.logging.*; -import org.redkale.util.Creator.Creators; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - * @param - */ -public final class ObjectPool implements Supplier { - - private static final Logger logger = Logger.getLogger(ObjectPool.class.getSimpleName()); - - private final boolean debug; - - private final Queue queue; - - private Creator creator; - - private final Consumer prepare; - - private final Predicate recycler; - - private final AtomicLong creatCounter; - - private final AtomicLong cycleCounter; - - public ObjectPool(Class clazz, Consumer prepare, Predicate recycler) { - this(2, clazz, prepare, recycler); - } - - public ObjectPool(int max, Class clazz, Consumer prepare, Predicate recycler) { - this(max, Creators.create(clazz), prepare, recycler); - } - - public ObjectPool(Creator creator, Consumer prepare, Predicate recycler) { - this(2, creator, prepare, recycler); - } - - public ObjectPool(int max, Creator creator, Consumer prepare, Predicate recycler) { - this(null, null, max, creator, prepare, recycler); - } - - public ObjectPool(AtomicLong creatCounter, AtomicLong cycleCounter, int max, Creator creator, Consumer prepare, Predicate recycler) { - this.creatCounter = creatCounter; - this.cycleCounter = cycleCounter; - this.creator = creator; - this.prepare = prepare; - this.recycler = recycler; - this.queue = new LinkedBlockingQueue(Math.max(Runtime.getRuntime().availableProcessors() * 2, max)); - this.debug = logger.isLoggable(Level.FINER); - } - - public void setCreator(Creator creator) { - this.creator = creator; - } - - @Override - public T get() { - T result = queue.poll(); - if (result == null) { - if (creatCounter != null) creatCounter.incrementAndGet(); - result = this.creator.create(); - } - if (prepare != null) prepare.accept(result); - return result; - } - - public void offer(final T e) { - if (e != null && recycler.test(e)) { - if (cycleCounter != null) cycleCounter.incrementAndGet(); - if (debug) { - for (T t : queue) { - if (t == e) { - logger.log(Level.WARNING, "[" + Thread.currentThread().getName() + "] repeat offer the same object(" + e + ")", new Exception()); - return; - } - } - } - queue.offer(e); - } - } - - public long getCreatCount() { - return creatCounter.longValue(); - } - - public long getCycleCount() { - return cycleCounter.longValue(); - } -} diff --git a/android-jdk6-redkale/src/org/redkale/util/Reproduce.java b/android-jdk6-redkale/src/org/redkale/util/Reproduce.java deleted file mode 100644 index d90c45d59..000000000 --- a/android-jdk6-redkale/src/org/redkale/util/Reproduce.java +++ /dev/null @@ -1,135 +0,0 @@ -package org.redkale.util; - -import java.lang.reflect.Modifier; -import java.util.function.Predicate; -import static org.objectweb.asm.Opcodes.*; -import org.objectweb.asm.*; - -public interface Reproduce { - - public D copy(D dest, S src); - - public static abstract class Reproduces { - - public static Reproduce create(final Class destClass, final Class srcClass) { - return create(destClass, srcClass, null); - } - - @SuppressWarnings("unchecked") - public static Reproduce create(final Class destClass, final Class srcClass, final Predicate columnPredicate) { - // ------------------------------------------------------------------------------ - final String supDynName = Reproduce.class.getName().replace('.', '/'); - final String destName = destClass.getName().replace('.', '/'); - final String srcName = srcClass.getName().replace('.', '/'); - final String destDesc = Type.getDescriptor(destClass); - final String srcDesc = Type.getDescriptor(srcClass); - String newDynName = supDynName + "Dyn_" + destClass.getSimpleName() + "_" + srcClass.getSimpleName(); - ClassLoader loader = Reproduce.class.getClassLoader(); - if (String.class.getClassLoader() != destClass.getClassLoader()) { - loader = destClass.getClassLoader(); - newDynName = destName + "_Dyn" + Reproduce.class.getSimpleName() + "_" + srcClass.getSimpleName(); - } - try { - return (Reproduce) Class.forName(newDynName.replace('/', '.')).newInstance(); - } catch (Exception ex) { - } - // ------------------------------------------------------------------------------ - ClassWriter cw = new ClassWriter(0); - FieldVisitor fv; - MethodVisitor mv; - AnnotationVisitor av0; - - cw.visit(V1_7, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, newDynName, "Ljava/lang/Object;L" + supDynName + "<" + destDesc + srcDesc + ">;", "java/lang/Object", new String[]{supDynName}); - - { // 构造函数 - mv = (cw.visitMethod(ACC_PUBLIC, "", "()V", null, null)); - //mv.setDebug(true); - mv.visitVarInsn(ALOAD, 0); - mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V", false); - mv.visitInsn(RETURN); - mv.visitMaxs(1, 1); - mv.visitEnd(); - } - { - mv = (cw.visitMethod(ACC_PUBLIC, "copy", "(" + destDesc + srcDesc + ")" + destDesc, null, null)); - //mv.setDebug(true); - - for (java.lang.reflect.Field field : srcClass.getFields()) { - if (Modifier.isStatic(field.getModifiers())) continue; - if (Modifier.isFinal(field.getModifiers())) continue; - if (!Modifier.isPublic(field.getModifiers())) continue; - final String fname = field.getName(); - try { - if (!field.getType().equals(destClass.getField(fname).getType())) continue; - if (!columnPredicate.test(fname)) continue; - } catch (Exception e) { - continue; - } - mv.visitVarInsn(ALOAD, 1); - mv.visitVarInsn(ALOAD, 2); - String td = Type.getDescriptor(field.getType()); - mv.visitFieldInsn(GETFIELD, srcName, fname, td); - mv.visitFieldInsn(PUTFIELD, destName, fname, td); - } - - for (java.lang.reflect.Method getter : srcClass.getMethods()) { - if (Modifier.isStatic(getter.getModifiers())) continue; - if (getter.getParameterTypes().length > 0) continue; - if ("getClass".equals(getter.getName())) continue; - if (!getter.getName().startsWith("get") && !getter.getName().startsWith("is")) continue; - java.lang.reflect.Method setter; - boolean is = getter.getName().startsWith("is"); - try { - setter = destClass.getMethod(getter.getName().replaceFirst(is ? "is" : "get", "set"), getter.getReturnType()); - if (columnPredicate != null) { - String col = setter.getName().substring(3); - if (col.length() < 2 || Character.isLowerCase(col.charAt(1))) { - char[] cs = col.toCharArray(); - cs[0] = Character.toLowerCase(cs[0]); - col = new String(cs); - } - if (!columnPredicate.test(col)) continue; - } - } catch (Exception e) { - continue; - } - mv.visitVarInsn(ALOAD, 1); - mv.visitVarInsn(ALOAD, 2); - mv.visitMethodInsn(INVOKEVIRTUAL, srcName, getter.getName(), Type.getMethodDescriptor(getter), false); - mv.visitMethodInsn(INVOKEVIRTUAL, destName, setter.getName(), Type.getMethodDescriptor(setter), false); - } - mv.visitVarInsn(ALOAD, 1); - mv.visitInsn(ARETURN); - mv.visitMaxs(3, 3); - mv.visitEnd(); - } - { - mv = (cw.visitMethod(ACC_PUBLIC + ACC_BRIDGE + ACC_SYNTHETIC, "copy", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", null, null)); - //mv.setDebug(true); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ALOAD, 1); - mv.visitTypeInsn(CHECKCAST, destName); - mv.visitVarInsn(ALOAD, 2); - mv.visitTypeInsn(CHECKCAST, srcName); - mv.visitMethodInsn(INVOKEVIRTUAL, newDynName, "copy", "(" + destDesc + srcDesc + ")" + destDesc, false); - mv.visitInsn(ARETURN); - mv.visitMaxs(3, 3); - mv.visitEnd(); - } - cw.visitEnd(); - // ------------------------------------------------------------------------------ - byte[] bytes = cw.toByteArray(); - Class creatorClazz = new ClassLoader(loader) { - public final Class loadClass(String name, byte[] b) { - return defineClass(name, b, 0, b.length); - } - }.loadClass(newDynName.replace('/', '.'), bytes); - try { - return (Reproduce) creatorClazz.newInstance(); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/util/ResourceFactory.java b/android-jdk6-redkale/src/org/redkale/util/ResourceFactory.java deleted file mode 100644 index d3af21809..000000000 --- a/android-jdk6-redkale/src/org/redkale/util/ResourceFactory.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.util; - -import java.lang.reflect.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.logging.*; -import java.util.regex.*; -import javax.annotation.*; - -/** - * 如果Resource(name = "$") 表示资源name采用所属对象的name - * - * @see http://www.redkale.org - * @author zhangjx - */ -@SuppressWarnings("unchecked") -public final class ResourceFactory { - - public static final String RESOURCE_PARENT_NAME = "$"; - - private static final Logger logger = Logger.getLogger(ResourceFactory.class.getSimpleName()); - - private final ResourceFactory parent; - - private static final ResourceFactory instance = new ResourceFactory(null); - - private final ConcurrentHashMap interceptmap = new ConcurrentHashMap(); - - private final ConcurrentHashMap, ConcurrentHashMap> store = new ConcurrentHashMap(); - - private final ConcurrentHashMap> gencstore = new ConcurrentHashMap(); - - private ResourceFactory(ResourceFactory parent) { - this.parent = parent; - } - - public static ResourceFactory root() { - return instance; - } - - public ResourceFactory createChild() { - return new ResourceFactory(this); - } - - public void release() { - this.store.clear(); - } - - public void register(final Class clazz, final Object rs) { - register("", clazz, rs); - } - - public void register(final Object rs) { - if (rs != null) register("", rs.getClass(), rs); - } - - public void add(final Type clazz, final Intercepter rs) { - if (clazz == null || rs == null) return; - interceptmap.put(clazz, rs); - } - - public void register(final String name, final Object rs) { - register(name, rs.getClass(), rs); - } - - public void register(final String name, final Class clazz, final A rs) { - ConcurrentHashMap map = this.store.get(clazz); - if (map == null) { - ConcurrentHashMap sub = new ConcurrentHashMap(); - sub.put(name, rs); - store.put(clazz, sub); - } else { - map.put(name, rs); - } - } - - public void register(final String name, final Type clazz, final A rs) { - if (clazz instanceof Class) { - register(name, (Class) clazz, rs); - return; - } - ConcurrentHashMap map = this.gencstore.get(clazz); - if (map == null) { - ConcurrentHashMap sub = new ConcurrentHashMap(); - sub.put(name, rs); - gencstore.put(clazz, sub); - } else { - map.put(name, rs); - } - } - - public A find(Class clazz) { - return find("", clazz); - } - - public A find(String name, Type clazz) { - Map map = this.gencstore.get(clazz); - if (map != null) { - A rs = (A) map.get(name); - if (rs != null) return rs; - } - if (parent != null) return parent.find(name, clazz); - return null; - } - - public A find(String name, Class clazz) { - Map map = this.store.get(clazz); - if (map != null) { - A rs = (A) map.get(name); - if (rs != null) return rs; - } - if (parent != null) return parent.find(name, clazz); - return null; - } - - public A findChild(final String name, final Class clazz) { - A rs = find(name, clazz); - if (rs != null) return rs; - for (Map.Entry, ConcurrentHashMap> en : this.store.entrySet()) { //不用forEach为兼容JDK 6 - if (!clazz.isAssignableFrom(en.getKey())) continue; - Object v = en.getValue().get(name); - if (v != null) return (A) v; - } - return null; - } - - public Map find(final Pattern reg, Class clazz, A exclude) { - Map result = new LinkedHashMap(); - load(reg, clazz, exclude, result); - return result; - } - - private void load(final Pattern reg, Class clazz, final A exclude, final Map result) { - ConcurrentHashMap map = this.store.get(clazz); - if (map != null) { - for (Map.Entry en : map.entrySet()) { // 不用forEach为兼容JDK 6 - String x = en.getKey(); - Object y = en.getValue(); - if (y != exclude && reg.matcher(x).find() && result.get(x) == null) result.put(x, (A) y); - } - } - if (parent != null) parent.load(reg, clazz, exclude, result); - } - - public boolean inject(final Object src) { - return inject(src, null); - } - - public boolean inject(final Object src, final T attachment) { - return inject(src, attachment, new ArrayList()); - } - - private boolean inject(final Object src, final T attachment, final List list) { - if (src == null) return false; - try { - list.add(src); - Class clazz = src.getClass(); - do { - for (Field field : clazz.getDeclaredFields()) { - if (Modifier.isStatic(field.getModifiers())) continue; - field.setAccessible(true); - final Class classtype = field.getType(); - final Type genctype = field.getGenericType(); - Resource rc = field.getAnnotation(Resource.class); - if (rc == null) { - boolean flag = true; - Object ns = field.get(src); - for (Object o : list) { - if (o == ns) { - flag = false; - break; - } - } - if (ns == null) continue; - if (ns.getClass().isPrimitive() || ns.getClass().isArray() || ns.getClass().getName().startsWith("java")) continue; - if (flag) this.inject(ns, attachment, list); - continue; - } - if (Modifier.isFinal(field.getModifiers())) continue; - final String rcname = (rc.name().contains(RESOURCE_PARENT_NAME) && src instanceof Nameable) ? rc.name().replace(RESOURCE_PARENT_NAME, ((Nameable) src).name()) : rc.name(); - Object rs = genctype == classtype ? null : find(rcname, genctype); - if (rs == null) { - if (Map.class.isAssignableFrom(classtype)) { - rs = find(Pattern.compile(rcname.isEmpty() ? ".*" : rcname), (Class) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[1], src); - } else if (rcname.startsWith("property.")) { - rs = find(rcname, String.class); - } else { - rs = find(rcname, classtype); - } - } - if (rs == null) { - Intercepter it = findIntercepter(field.getGenericType(), field); - if (it != null) it.invoke(this, src, field, attachment); - continue; - } - if (!rs.getClass().isPrimitive() && classtype.isPrimitive()) { - if (classtype == int.class) { - rs = Integer.decode(rs.toString()); - } else if (classtype == long.class) { - rs = Long.decode(rs.toString()); - } else if (classtype == short.class) { - rs = Short.decode(rs.toString()); - } else if (classtype == boolean.class) { - rs = "true".equalsIgnoreCase(rs.toString()); - } else if (classtype == byte.class) { - rs = Byte.decode(rs.toString()); - } else if (classtype == float.class) { - rs = Float.parseFloat(rs.toString()); - } else if (classtype == double.class) { - rs = Double.parseDouble(rs.toString()); - } - } - field.set(src, rs); - } - } while ((clazz = clazz.getSuperclass()) != Object.class); - return true; - } catch (Exception ex) { - logger.log(Level.FINER, "inject " + src + " error", ex); - return false; - } - } - - private Intercepter findIntercepter(Type ft, Field field) { - Intercepter it = this.interceptmap.get(ft); - if (it != null) return it; - Class c = field.getType(); - for (Map.Entry en : this.interceptmap.entrySet()) { - Type t = en.getKey(); - if (t == ft) return en.getValue(); - if (t instanceof Class && (((Class) t)).isAssignableFrom(c)) return en.getValue(); - } - return parent == null ? null : parent.findIntercepter(ft, field); - } - - public static interface Intercepter { - - public void invoke(ResourceFactory factory, Object src, Field field, Object attachment); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/util/SelectColumn.java b/android-jdk6-redkale/src/org/redkale/util/SelectColumn.java deleted file mode 100644 index d1ef10ecd..000000000 --- a/android-jdk6-redkale/src/org/redkale/util/SelectColumn.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.util; - -import java.util.*; -import java.util.function.*; -import java.util.regex.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public class SelectColumn implements Predicate { - - private Pattern[] patterns; - - private String[] columns; - - private boolean excludable; //是否排除 - - public SelectColumn() { - } - - protected SelectColumn(final String[] columns0, final boolean excludable) { - this.excludable = excludable; - final int len = columns0.length; - if (len < 1) return; - Pattern[] regs = null; - String[] cols = null; - int regcount = 0; - int colcount = 0; - for (String col : columns0) { - boolean reg = false; - for (int i = 0; i < col.length(); i++) { - char ch = col.charAt(i); - if (ch == '^' || ch == '$' || ch == '*' || ch == '?' || ch == '+' || ch == '[' || ch == '(') { - reg = true; - break; - } - } - if (reg) { - if (regs == null) regs = new Pattern[len]; - regs[regcount++] = Pattern.compile(col); - } else { - if (cols == null) cols = new String[len]; - cols[colcount++] = col; - } - } - if (regs != null) { - if (regcount == len) { - this.patterns = regs; - } else { - this.patterns = Arrays.copyOf(regs, regcount); - } - } - if (cols != null) { - if (colcount == len) { - this.columns = cols; - } else { - this.columns = Arrays.copyOf(cols, colcount); - } - } - } - - /** - * class中的字段名 - * - * @param columns - * @return - */ - public static SelectColumn createIncludes(String... columns) { - return new SelectColumn(columns, false); - } - - /** - * class中的字段名 - * - * @param columns - * @return - */ - public static SelectColumn createExcludes(String... columns) { - return new SelectColumn(columns, true); - } - - @Override - public boolean test(final String column) { - if (this.columns != null) { - for (String col : this.columns) { - if (col.equalsIgnoreCase(column)) return !excludable; - } - } - if (this.patterns != null) { - for (Pattern reg : this.patterns) { - if (reg.matcher(column).find()) return !excludable; - } - } - return excludable; - } - - public String[] getColumns() { - return columns; - } - - public void setColumns(String[] columns) { - this.columns = columns; - } - - public boolean isExcludable() { - return excludable; - } - - public void setExcludable(boolean excludable) { - this.excludable = excludable; - } - - public Pattern[] getPatterns() { - return patterns; - } - - public void setPatterns(Pattern[] patterns) { - this.patterns = patterns; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(getClass().getSimpleName()).append("{excludable=").append(excludable); - if (columns != null) sb.append(", columns=").append(Arrays.toString(columns)); - if (patterns != null) sb.append(", patterns=").append(Arrays.toString(patterns)); - return sb.append('}').toString(); - } - -} diff --git a/android-jdk6-redkale/src/org/redkale/util/Sheet.java b/android-jdk6-redkale/src/org/redkale/util/Sheet.java deleted file mode 100644 index cd456cfd9..000000000 --- a/android-jdk6-redkale/src/org/redkale/util/Sheet.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.util; - -import java.util.*; - -/** - * 页集合。 结构由一个total总数和一个List列表组合而成。 - * - * @see http://www.redkale.org - * @author zhangjx - * @param - */ -@SuppressWarnings("unchecked") -public class Sheet implements java.io.Serializable { - - private long total = -1; - - private Collection rows; - - public Sheet() { - super(); - } - - public Sheet(int total, Collection data) { - this((long) total, data); - } - - public Sheet(long total, Collection data) { - this.total = total; - this.rows = (Collection) data; - } - - public static Sheet asSheet(Collection data) { - return data == null ? new Sheet() : new Sheet(data.size(), data); - } - - public Sheet copyTo(Sheet copy) { - if (copy == null) return copy; - copy.total = this.total; - if (this.getRows() != null) { - copy.setRows(new ArrayList(this.getRows())); - } else { - copy.rows = null; - } - return copy; - } - - /** - * 判断数据列表是否为空 - * - * @return - */ - public boolean isEmpty() { - return this.rows == null || this.rows.isEmpty(); - } - - @Override - public String toString() { - return "Sheet[total=" + this.total + ", rows=" + this.rows + "]"; - } - - public long getTotal() { - return this.total; - } - - public void setTotal(long total) { - this.total = total; - } - - public Collection getRows() { - return this.rows; - } - - public List list() { - return list(false); - } - - public List list(boolean created) { - if (this.rows == null) return created ? new ArrayList() : null; - return (this.rows instanceof List) ? (List) this.rows : new ArrayList(this.rows); - } - - public void setRows(Collection data) { - this.rows = (Collection) data; - } -} diff --git a/android-jdk6-redkale/src/org/redkale/util/TypeToken.java b/android-jdk6-redkale/src/org/redkale/util/TypeToken.java deleted file mode 100644 index 78dea9238..000000000 --- a/android-jdk6-redkale/src/org/redkale/util/TypeToken.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.util; - -import java.lang.reflect.Type; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.WildcardType; -import java.lang.reflect.TypeVariable; -import java.lang.reflect.GenericArrayType; -import java.util.*; -import static org.objectweb.asm.Opcodes.*; -import org.objectweb.asm.*; - -/** - * - * 获取泛型的Type类 - * - * @see http://www.redkale.org - * @author zhangjx - * @param - */ -public abstract class TypeToken { - - private final Type type; - - public TypeToken() { - type = ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; - } - - public final Type getType() { - return type; - } - - /** - * 判断Type是否能确定最终的class, 是则返回true,存在通配符或者不确定类型则返回false。 - * 例如: Map< String, String > 返回 ture; Map< ? extends Serializable, String > 返回false; - * - * @param type - * @return - */ - public final static boolean isClassType(final Type type) { - if (type instanceof Class) return true; - if (type instanceof WildcardType) return false; - if (type instanceof TypeVariable) return false; - if (type instanceof GenericArrayType) return isClassType(((GenericArrayType) type).getGenericComponentType()); - if (!(type instanceof ParameterizedType)) return false; //只能是null了 - final ParameterizedType ptype = (ParameterizedType) type; - if (ptype.getOwnerType() != null && !isClassType(ptype.getOwnerType())) return false; - if (!isClassType(ptype.getRawType())) return false; - for (Type t : ptype.getActualTypeArguments()) { - if (!isClassType(t)) return false; - } - return true; - } - - /** - * 动态创建 ParameterizedType - * - * @param ownerType0 - * @param rawType0 - * @param actualTypeArguments0 - * @return - */ - public static Type createParameterizedType(final Type ownerType0, final Type rawType0, final Type... actualTypeArguments0) { - if (ownerType0 == null && rawType0 instanceof Class) { - int count = 0; - for (Type t : actualTypeArguments0) { - if (isClassType(t)) count++; - } - if (count == actualTypeArguments0.length) return createParameterizedType((Class) rawType0, actualTypeArguments0); - } - return new ParameterizedType() { - private final Class rawType = (Class) rawType0; - - private final Type ownerType = ownerType0; - - private final Type[] actualTypeArguments = actualTypeArguments0; - - @Override - public Type[] getActualTypeArguments() { - return actualTypeArguments.clone(); - } - - @Override - public Type getRawType() { - return rawType; - } - - @Override - public Type getOwnerType() { - return ownerType; - } - - @Override - public int hashCode() { - return Arrays.hashCode(actualTypeArguments) ^ Objects.hashCode(rawType) ^ Objects.hashCode(ownerType); - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof ParameterizedType)) return false; - final ParameterizedType that = (ParameterizedType) o; - if (this == that) return true; - return Objects.equals(ownerType, that.getOwnerType()) - && Objects.equals(rawType, that.getRawType()) - && Arrays.equals(actualTypeArguments, that.getActualTypeArguments()); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - if (ownerType != null) sb.append((ownerType instanceof Class) ? (((Class) ownerType).getName()) : ownerType.toString()).append("."); - sb.append(rawType.getName()); - - if (actualTypeArguments != null && actualTypeArguments.length > 0) { - sb.append("<"); - boolean first = true; - for (Type t : actualTypeArguments) { - if (!first) sb.append(", "); - sb.append(t); - first = false; - } - sb.append(">"); - } - return sb.toString(); - } - }; - } - - private static Type createParameterizedType(final Class rawType, final Type... actualTypeArguments) { - ClassLoader loader = TypeToken.class.getClassLoader(); - String newDynName = TypeToken.class.getName().replace('.', '/') + "_Dyn" + System.currentTimeMillis(); - for (;;) { - try { - Class.forName(newDynName.replace('/', '.')); - newDynName = TypeToken.class.getName().replace('.', '/') + "_Dyn" + Math.abs(System.nanoTime()); - } catch (Exception ex) { //异常说明类不存在 - break; - } - } - ClassWriter cw = new ClassWriter(0); - FieldVisitor fv; - MethodVisitor mv; - cw.visit(V1_7, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, newDynName, null, "java/lang/Object", null); - String rawTypeDesc = org.objectweb.asm.Type.getDescriptor(rawType); - StringBuilder sb = new StringBuilder(); - sb.append(rawTypeDesc.substring(0, rawTypeDesc.length() - 1)).append('<'); - for (Type c : actualTypeArguments) { - sb.append(getClassTypeDescriptor(c)); - } - sb.append(">;"); - { - fv = cw.visitField(ACC_PUBLIC, "field", rawTypeDesc, sb.toString(), null); - fv.visitEnd(); - } - {//构造方法 - mv = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null); - mv.visitVarInsn(ALOAD, 0); - mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V", false); - mv.visitInsn(RETURN); - mv.visitMaxs(1, 1); - mv.visitEnd(); - } - cw.visitEnd(); - byte[] bytes = cw.toByteArray(); - Class newClazz = new ClassLoader(loader) { - public final Class loadClass(String name, byte[] b) { - return defineClass(name, b, 0, b.length); - } - }.loadClass(newDynName.replace('/', '.'), bytes); - try { - return newClazz.getField("field").getGenericType(); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - - private static CharSequence getClassTypeDescriptor(Type type) { - if (!isClassType(type)) throw new IllegalArgumentException(type + " not a class type"); - if (type instanceof Class) return org.objectweb.asm.Type.getDescriptor((Class) type); - final ParameterizedType pt = (ParameterizedType) type; - CharSequence rawTypeDesc = getClassTypeDescriptor(pt.getRawType()); - StringBuilder sb = new StringBuilder(); - sb.append(rawTypeDesc.subSequence(0, rawTypeDesc.length() - 1)).append('<'); - for (Type c : pt.getActualTypeArguments()) { - sb.append(getClassTypeDescriptor(c)); - } - sb.append(">;"); - return sb; - } -} diff --git a/android-jdk6-redkale/src/org/redkale/util/Utility.java b/android-jdk6-redkale/src/org/redkale/util/Utility.java deleted file mode 100644 index bfde27452..000000000 --- a/android-jdk6-redkale/src/org/redkale/util/Utility.java +++ /dev/null @@ -1,554 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.util; - -import java.io.*; -import java.net.*; -import java.nio.ByteBuffer; -import java.nio.charset.*; -import java.util.*; -import javax.net.ssl.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public final class Utility { - - private static final int zoneRawOffset = TimeZone.getDefault().getRawOffset(); - - private static final String format = "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS.%tL"; - - private static final Charset UTF_8 = Charset.forName("UTF-8"); - - private static final char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - - private static final javax.net.ssl.SSLContext DEFAULTSSL_CONTEXT; - - static { - - try { - DEFAULTSSL_CONTEXT = javax.net.ssl.SSLContext.getInstance("SSL"); - DEFAULTSSL_CONTEXT.init(null, new javax.net.ssl.TrustManager[]{new javax.net.ssl.X509TrustManager() { - @Override - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return null; - } - - @Override - public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) throws java.security.cert.CertificateException { - } - - @Override - public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) throws java.security.cert.CertificateException { - } - }}, null); - } catch (Exception e) { - throw new RuntimeException(e); //不可能会发生 - } - } - - private Utility() { - } - - public static String now() { - return String.format(format, System.currentTimeMillis()); - } - - public static void println(String string, ByteBuffer buffer) { - if (buffer == null || !buffer.hasRemaining()) return; - byte[] bytes = new byte[buffer.remaining()]; - buffer.get(bytes); - buffer.flip(); - println(string, bytes); - } - - public static void println(String string, byte... bytes) { - if (bytes == null) return; - StringBuilder sb = new StringBuilder(); - if (string != null) sb.append(string); - sb.append(bytes.length).append(".["); - boolean last = false; - for (byte b : bytes) { - if (last) sb.append(','); - int v = b & 0xff; - if (v < 16) sb.append('0'); - sb.append(Integer.toHexString(v)); - last = true; - } - sb.append(']'); - (System.out).println(sb); - } - - /** - * 返回本机的第一个内网IPv4地址, 没有则返回null - *

- * @return - */ - public static InetAddress localInetAddress() { - InetAddress back = null; - try { - Enumeration nifs = NetworkInterface.getNetworkInterfaces(); - while (nifs.hasMoreElements()) { - NetworkInterface nif = nifs.nextElement(); - if (!nif.isUp()) continue; - Enumeration eis = nif.getInetAddresses(); - while (eis.hasMoreElements()) { - InetAddress ia = eis.nextElement(); - if (ia.isLoopbackAddress()) back = ia; - if (ia.isSiteLocalAddress()) return ia; - } - } - } catch (Exception e) { - e.printStackTrace(); - } - return back; - } - - /** - * 获取当天凌晨零点的格林时间 - * - * @return - */ - public static long midnight() { - return midnight(System.currentTimeMillis()); - } - - /** - * 获取指定时间当天凌晨零点的格林时间 - * - * @param time - * @return - */ - public static long midnight(long time) { - return (time + zoneRawOffset) / 86400000 * 86400000 - zoneRawOffset; - } - - /** - * 获取当天20151231格式的int值 - * - * @return - */ - public static int today() { - final Calendar cal = Calendar.getInstance(); - return cal.get(Calendar.YEAR) * 10000 + (cal.get(Calendar.MONTH) + 1) * 100 + cal.get(Calendar.DAY_OF_MONTH); - } - - /** - * 获取时间点所在星期的周一 - * - * @param time - * @return - */ - public static long monday(long time) { - final Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(time); - cal.set(Calendar.HOUR_OF_DAY, 0); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MILLISECOND, 0); - cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); - return cal.getTimeInMillis(); - } - - /** - * 获取时间点所在星期的周日 - * - * @param time - * @return - */ - public static long sunday(long time) { - final Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(time); - cal.set(Calendar.HOUR_OF_DAY, 0); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MILLISECOND, 0); - cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); - return cal.getTimeInMillis(); - } - - /** - * 获取时间点所在月份的1号 - * - * @param time - * @return - */ - public static long monthFirstDay(long time) { - final Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(time); - cal.set(Calendar.HOUR_OF_DAY, 0); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MILLISECOND, 0); - cal.set(Calendar.DAY_OF_MONTH, 1); - return cal.getTimeInMillis(); - } - - public static String binToHexString(byte[] bytes) { - return new String(binToHex(bytes)); - } - - public static char[] binToHex(byte[] bytes) { - return binToHex(bytes, 0, bytes.length); - } - - public static String binToHexString(byte[] bytes, int offset, int len) { - return new String(binToHex(bytes, offset, len)); - } - - public static char[] binToHex(byte[] bytes, int offset, int len) { - final char[] sb = new char[len * 2]; - final int end = offset + len; - int index = 0; - final char[] hexs = hex; - for (int i = offset; i < end; i++) { - byte b = bytes[i]; - sb[index++] = (hexs[((b >> 4) & 0xF)]); - sb[index++] = hexs[((b) & 0xF)]; - } - return sb; - } - - public static byte[] hexToBin(CharSequence src) { - return hexToBin(src, 0, src.length()); - } - - public static byte[] hexToBin(CharSequence src, int offset, int len) { - final int size = (len + 1) / 2; - final byte[] bytes = new byte[size]; - final int end = offset + len; - String digits = "0123456789abcdef"; - for (int i = 0; i < size; i++) { - int ch1 = src.charAt(offset + i * 2); - if ('A' <= ch1 && 'F' >= ch1) ch1 = ch1 - 'A' + 'a'; - int ch2 = src.charAt(offset + i * 2 + 1); - if ('A' <= ch2 && 'F' >= ch2) ch2 = ch2 - 'A' + 'a'; - int pos1 = digits.indexOf(ch1); - if (pos1 < 0) throw new NumberFormatException(); - int pos2 = digits.indexOf(ch2); - if (pos2 < 0) throw new NumberFormatException(); - bytes[i] = (byte) (pos1 * 0x10 + pos2); - } - return bytes; - } - - public static byte[] hexToBin(String str) { - return hexToBin(charArray(str)); - } - - public static byte[] hexToBin(char[] src) { - return hexToBin(src, 0, src.length); - } - - public static byte[] hexToBin(char[] src, int offset, int len) { - final int size = (len + 1) / 2; - final byte[] bytes = new byte[size]; - final int end = offset + len; - String digits = "0123456789abcdef"; - for (int i = 0; i < size; i++) { - int ch1 = src[offset + i * 2]; - if ('A' <= ch1 && 'F' >= ch1) ch1 = ch1 - 'A' + 'a'; - int ch2 = src[offset + i * 2 + 1]; - if ('A' <= ch2 && 'F' >= ch2) ch2 = ch2 - 'A' + 'a'; - int pos1 = digits.indexOf(ch1); - if (pos1 < 0) throw new NumberFormatException(); - int pos2 = digits.indexOf(ch2); - if (pos2 < 0) throw new NumberFormatException(); - bytes[i] = (byte) (pos1 * 0x10 + pos2); - } - return bytes; - } - - //----------------------------------------------------------------------------- - public static char[] decodeUTF8(final byte[] array) { - return decodeUTF8(array, 0, array.length); - } - - public static char[] decodeUTF8(final byte[] array, final int start, final int len) { - byte b; - int size = len; - final byte[] bytes = array; - final int limit = start + len; - for (int i = start; i < limit; i++) { - b = bytes[i]; - if ((b >> 5) == -2) { - size--; - } else if ((b >> 4) == -2) { - size -= 2; - } - } - final char[] text = new char[size]; - size = 0; - for (int i = start; i < limit;) { - b = bytes[i++]; - if (b >= 0) { - text[size++] = (char) b; - } else if ((b >> 5) == -2) { - text[size++] = (char) (((b << 6) ^ bytes[i++]) ^ (((byte) 0xC0 << 6) ^ ((byte) 0x80))); - } else if ((b >> 4) == -2) { - text[size++] = (char) ((b << 12) ^ (bytes[i++] << 6) ^ (bytes[i++] ^ (((byte) 0xE0 << 12) ^ ((byte) 0x80 << 6) ^ ((byte) 0x80)))); - } - } - return text; - } - - public static byte[] encodeUTF8(final String value) { - if (value == null) return new byte[0]; - return encodeUTF8(value.toCharArray()); - } - - public static byte[] encodeUTF8(final char[] array) { - return encodeUTF8(array, 0, array.length); - } - - public static byte[] encodeUTF8(final char[] text, final int start, final int len) { - char c; - int size = 0; - final char[] chars = text; - final int limit = start + len; - for (int i = start; i < limit; i++) { - c = chars[i]; - if (c < 0x80) { - size++; - } else if (c < 0x800) { - size += 2; - } else { - size += 3; - } - } - final byte[] bytes = new byte[size]; - size = 0; - for (int i = start; i < limit; i++) { - c = chars[i]; - if (c < 0x80) { - bytes[size++] = (byte) c; - } else if (c < 0x800) { - bytes[size++] = (byte) (0xc0 | (c >> 6)); - bytes[size++] = (byte) (0x80 | (c & 0x3f)); - } else { - bytes[size++] = (byte) (0xe0 | ((c >> 12))); - bytes[size++] = (byte) (0x80 | ((c >> 6) & 0x3f)); - bytes[size++] = (byte) (0x80 | (c & 0x3f)); - } - } - return bytes; - } - - public static char[] charArray(String value) { //与JDK 8 的实现版本不一样 - return value == null ? null : value.toCharArray(); - } - - public static char[] charArray(StringBuilder value) { //与JDK 8 的实现版本不一样 - return value == null ? null : value.toString().toCharArray(); - } - - public static ByteBuffer encodeUTF8(final ByteBuffer buffer, final char[] array) { - return encodeUTF8(buffer, array, 0, array.length); - } - - public static ByteBuffer encodeUTF8(final ByteBuffer buffer, int bytesLength, final char[] array) { - return encodeUTF8(buffer, bytesLength, array, 0, array.length); - } - - public static int encodeUTF8Length(String value) { - if (value == null) return -1; - return encodeUTF8Length(value.toCharArray()); - } - - public static int encodeUTF8Length(final char[] text) { - return encodeUTF8Length(text, 0, text.length); - } - - public static int encodeUTF8Length(final char[] text, final int start, final int len) { - char c; - int size = 0; - final char[] chars = text; - final int limit = start + len; - for (int i = start; i < limit; i++) { - c = chars[i]; - size += (c < 0x80 ? 1 : (c < 0x800 ? 2 : 3)); - } - return size; - } - - /** - * 将两个数字组装成一个long - *

- * @param high - * @param low - * @return - */ - public static long merge(int high, int low) { - return (0L + high) << 32 | low; - } - - public static ByteBuffer encodeUTF8(final ByteBuffer buffer, final char[] text, final int start, final int len) { - return encodeUTF8(buffer, encodeUTF8Length(text, start, len), text, start, len); - } - - public static ByteBuffer encodeUTF8(final ByteBuffer buffer, int bytesLength, final char[] text, final int start, final int len) { - char c; - char[] chars = text; - final int limit = start + len; - int remain = buffer.remaining(); - final ByteBuffer buffer2 = remain >= bytesLength ? null : ByteBuffer.allocate(bytesLength - remain + 3); //最差情况buffer最后两byte没有填充 - ByteBuffer buf = buffer; - for (int i = start; i < limit; i++) { - c = chars[i]; - if (c < 0x80) { - if (buf.remaining() < 1) buf = buffer2; - buf.put((byte) c); - } else if (c < 0x800) { - if (buf.remaining() < 2) buf = buffer2; - buf.put((byte) (0xc0 | (c >> 6))); - buf.put((byte) (0x80 | (c & 0x3f))); - } else { - if (buf.remaining() < 3) buf = buffer2; - buf.put((byte) (0xe0 | ((c >> 12)))); - buf.put((byte) (0x80 | ((c >> 6) & 0x3f))); - buf.put((byte) (0x80 | (c & 0x3f))); - } - } - if (buffer2 != null) buffer2.flip(); - return buffer2; - } - - //----------------------------------------------------------------------------- - public static javax.net.ssl.SSLContext getDefaultSSLContext() { - return DEFAULTSSL_CONTEXT; - } - - public static Socket createDefaultSSLSocket(InetSocketAddress address) throws IOException { - return createDefaultSSLSocket(address.getAddress(), address.getPort()); - } - - public static Socket createDefaultSSLSocket(InetAddress host, int port) throws IOException { - Socket socket = DEFAULTSSL_CONTEXT.getSocketFactory().createSocket(host, port); - - return socket; - } - - public static String postHttpContent(String url) throws IOException { - return remoteHttpContent(null, "POST", url, null, null).toString("UTF-8"); - } - - public static String postHttpContent(String url, String body) throws IOException { - return remoteHttpContent(null, "POST", url, null, body).toString("UTF-8"); - } - - public static String postHttpContent(String url, Map headers, String body) throws IOException { - return remoteHttpContent(null, "POST", url, headers, body).toString("UTF-8"); - } - - public static String postHttpContent(SSLContext ctx, String url) throws IOException { - return remoteHttpContent(ctx, "POST", url, null, null).toString("UTF-8"); - } - - public static String postHttpContent(SSLContext ctx, String url, String body) throws IOException { - return remoteHttpContent(ctx, "POST", url, null, body).toString("UTF-8"); - } - - public static String postHttpContent(SSLContext ctx, String url, Map headers, String body) throws IOException { - return remoteHttpContent(ctx, "POST", url, headers, body).toString("UTF-8"); - } - - public static byte[] postHttpBytesContent(String url) throws IOException { - return remoteHttpContent(null, "POST", url, null, null).toByteArray(); - } - - public static byte[] postHttpBytesContent(SSLContext ctx, String url) throws IOException { - return remoteHttpContent(ctx, "POST", url, null, null).toByteArray(); - } - - public static byte[] postHttpBytesContent(String url, Map headers, String body) throws IOException { - return remoteHttpContent(null, "POST", url, headers, body).toByteArray(); - } - - public static byte[] postHttpBytesContent(SSLContext ctx, String url, Map headers, String body) throws IOException { - return remoteHttpContent(ctx, "POST", url, headers, body).toByteArray(); - } - - public static String getHttpContent(String url) throws IOException { - return remoteHttpContent(null, "GET", url, null, null).toString("UTF-8"); - } - - public static String getHttpContent(SSLContext ctx, String url) throws IOException { - return remoteHttpContent(ctx, "GET", url, null, null).toString("UTF-8"); - } - - public static String getHttpContent(SSLContext ctx, String url, Map headers, String body) throws IOException { - return remoteHttpContent(ctx, "GET", url, headers, body).toString("UTF-8"); - } - - public static String getHttpContent(String url, Map headers, String body) throws IOException { - return remoteHttpContent(null, "GET", url, headers, body).toString("UTF-8"); - } - - public static byte[] getHttpBytesContent(String url) throws IOException { - return remoteHttpContent(null, "GET", url, null, null).toByteArray(); - } - - public static byte[] getHttpBytesContent(SSLContext ctx, String url) throws IOException { - return remoteHttpContent(ctx, "GET", url, null, null).toByteArray(); - } - - public static byte[] getHttpBytesContent(String url, Map headers, String body) throws IOException { - return remoteHttpContent(null, "GET", url, headers, body).toByteArray(); - } - - public static byte[] getHttpBytesContent(SSLContext ctx, String url, Map headers, String body) throws IOException { - return remoteHttpContent(ctx, "GET", url, headers, body).toByteArray(); - } - - protected static ByteArrayOutputStream remoteHttpContent(SSLContext ctx, String method, String url, Map headers, String body) throws IOException { - HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); - conn.setConnectTimeout(3000); - conn.setReadTimeout(3000); - if (conn instanceof HttpsURLConnection) ((HttpsURLConnection) conn).setSSLSocketFactory((ctx == null ? DEFAULTSSL_CONTEXT : ctx).getSocketFactory()); - conn.setRequestMethod(method); - if (headers != null) { - for (Map.Entry en : headers.entrySet()) { //不用forEach是为了兼容JDK 6 - conn.setRequestProperty(en.getKey(), en.getValue()); - } - } - if (body != null) { - conn.setDoInput(true); - conn.setDoOutput(true); - conn.getOutputStream().write(body.getBytes(UTF_8)); - } - conn.connect(); - int rs = conn.getResponseCode(); - if (rs == 301 || rs == 302) { - String newurl = conn.getHeaderField("Location"); - conn.disconnect(); - return remoteHttpContent(ctx, method, newurl, headers, body); - } - InputStream in = conn.getInputStream(); - ByteArrayOutputStream out = new ByteArrayOutputStream(1024); - byte[] bytes = new byte[1024]; - int pos; - while ((pos = in.read(bytes)) != -1) { - out.write(bytes, 0, pos); - } - conn.disconnect(); - return out; - } - - public static String read(InputStream in) throws IOException { - return read(in, "UTF-8"); - } - - public static String read(InputStream in, String charsetName) throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(1024); - byte[] bytes = new byte[1024]; - int pos; - while ((pos = in.read(bytes)) != -1) { - out.write(bytes, 0, pos); - } - return charsetName == null ? out.toString() : out.toString(charsetName); - } -} diff --git a/src-plugin/org/redkale/net/socks/NodeSocksServer.java b/src-plugin/org/redkale/net/socks/NodeSocksServer.java deleted file mode 100644 index 212e3b242..000000000 --- a/src-plugin/org/redkale/net/socks/NodeSocksServer.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.net.socks; - -import org.redkale.net.Server; -import org.redkale.util.AnyValue; -import org.redkale.boot.Application; -import org.redkale.net.Servlet; -import org.redkale.boot.ClassFilter; -import org.redkale.boot.NodeServer; -import org.redkale.boot.NodeProtocol; -import org.redkale.boot.ClassFilter.FilterEntry; -import static org.redkale.boot.NodeServer.LINE_SEPARATOR; -import org.redkale.util.AnyValue.DefaultAnyValue; -import java.lang.reflect.*; -import java.net.*; -import java.util.logging.*; - -/** - * < server protocol="SOCKS" host="0.0.0.0" port="1080" bindaddr="外网IP"> < /server> - * - * @see http://www.redkale.org - * @author zhangjx - */ -@NodeProtocol({"SOCKS"}) -public class NodeSocksServer extends NodeServer { - - private final SocksServer socksServer; - - public NodeSocksServer(Application application, AnyValue serconf) { - super(application, application.getResourceFactory().createChild(), createServer(application, serconf)); - this.socksServer = (SocksServer) server; - } - - private static Server createServer(Application application, AnyValue serconf) { - return new SocksServer(application.getStartTime(), application.getWatchFactory()); - } - - @Override - public InetSocketAddress getSocketAddress() { - return socksServer == null ? null : socksServer.getSocketAddress(); - } - - @Override - protected ClassFilter createServletClassFilter() { - return createClassFilter(null, null, SocksServlet.class, null, "servlets", "servlet"); - } - - @Override - protected void loadServlet(ClassFilter servletFilter) throws Exception { - if (socksServer != null) loadSocksServlet(this.nodeConf.getAnyValue("servlets"), servletFilter); - } - - protected void loadSocksServlet(final AnyValue conf, ClassFilter filter) throws Exception { - final StringBuilder sb = logger.isLoggable(Level.FINE) ? new StringBuilder() : null; - final String threadName = "[" + Thread.currentThread().getName() + "] "; - for (FilterEntry en : filter.getFilterEntrys()) { - Class clazz = (Class) en.getType(); - if (Modifier.isAbstract(clazz.getModifiers())) continue; - final SocksServlet servlet = clazz.newInstance(); - factory.inject(servlet); - DefaultAnyValue servletConf = (DefaultAnyValue) en.getProperty(); - this.socksServer.addSocksServlet(servlet, servletConf); - if (sb != null) sb.append(threadName).append(" Loaded ").append(clazz.getName()).append(" --> ").append(servletConf).append(LINE_SEPARATOR); - } - if (sb != null && sb.length() > 0) logger.log(Level.FINE, sb.toString()); - } - -} diff --git a/src-plugin/org/redkale/net/socks/SocksConnectServlet.java b/src-plugin/org/redkale/net/socks/SocksConnectServlet.java deleted file mode 100644 index 9da7e7e74..000000000 --- a/src-plugin/org/redkale/net/socks/SocksConnectServlet.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.net.socks; - -import org.redkale.util.AnyValue; -import org.redkale.net.Context; -import org.redkale.util.Utility; -import org.redkale.util.AutoLoad; -import java.io.*; -import java.net.*; -import java.nio.*; -import java.util.logging.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -@AutoLoad(false) -public class SocksConnectServlet extends SocksServlet { - - private InetSocketAddress bindAddress; - - private byte[] bindAddressBytes = new byte[0]; - - @Override - public void init(Context context, AnyValue config) { - if (config == null) { - this.bindAddress = new InetSocketAddress(Utility.localInetAddress(), context.getServerAddress().getPort()); - } else { - this.bindAddress = new InetSocketAddress(config.getValue("bindaddr", Utility.localInetAddress().getHostAddress()), context.getServerAddress().getPort()); - } - Logger logger = context.getLogger(); - if (logger.isLoggable(Level.INFO)) logger.info("[" + Thread.currentThread().getName() + "] bindAddress = " + bindAddress); - ByteBuffer bb; - InetAddress addr = bindAddress.getAddress(); - if (addr instanceof Inet6Address) { - bb = ByteBuffer.allocate(1 + 16 + 2); - bb.put((byte) 0x04); - } else { - bb = ByteBuffer.allocate(1 + 4 + 2); - bb.put((byte) 0x01); - } - bb.put(addr.getAddress()); - bb.putChar((char) bindAddress.getPort()); - bb.flip(); - this.bindAddressBytes = bb.array(); - } - - @Override - public void execute(SocksRequest request, SocksResponse response) throws IOException { - response.getContext().submit(new SocksRunner((SocksContext) response.getContext(), response.removeChannel(), bindAddressBytes)); - response.finish(true); - } - -} diff --git a/src-plugin/org/redkale/net/socks/SocksContext.java b/src-plugin/org/redkale/net/socks/SocksContext.java deleted file mode 100644 index 7060dc51c..000000000 --- a/src-plugin/org/redkale/net/socks/SocksContext.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.net.socks; - -import java.net.*; -import java.nio.*; -import java.nio.channels.*; -import java.nio.charset.*; -import java.util.concurrent.*; -import java.util.logging.*; -import org.redkale.net.*; -import org.redkale.net.http.*; -import org.redkale.util.*; -import org.redkale.watch.*; - -/** - * - * @author zhangjx - */ -public class SocksContext extends HttpContext { - - protected final AsynchronousChannelGroup group; - - public SocksContext(long serverStartTime, Logger logger, ExecutorService executor, int bufferCapacity, ObjectPool bufferPool, - ObjectPool responsePool, int maxbody, Charset charset, InetSocketAddress address, PrepareServlet prepare, - WatchFactory watch, int readTimeoutSecond, int writeTimeoutSecond, String contextPath) { - super(serverStartTime, logger, executor, bufferCapacity, bufferPool, responsePool, maxbody, charset, - address, prepare, watch, readTimeoutSecond, writeTimeoutSecond, contextPath); - AsynchronousChannelGroup g = null; - try { - g = AsynchronousChannelGroup.withThreadPool(executor); - } catch (Exception e) { - e.printStackTrace(); - } - this.group = g; - } - - protected AsynchronousChannelGroup getAsynchronousChannelGroup() { - return group; - } - -} diff --git a/src-plugin/org/redkale/net/socks/SocksPrepareServlet.java b/src-plugin/org/redkale/net/socks/SocksPrepareServlet.java deleted file mode 100644 index c89bdae34..000000000 --- a/src-plugin/org/redkale/net/socks/SocksPrepareServlet.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.net.socks; - -import org.redkale.util.AnyValue; -import org.redkale.net.Context; -import org.redkale.net.PrepareServlet; -import java.io.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public final class SocksPrepareServlet extends PrepareServlet { - - private SocksServlet socksServlet = new SocksConnectServlet(); - - private SocksProxyServlet proxyServlet = new SocksProxyServlet(); - - public SocksPrepareServlet() { - } - - @Override - public void init(Context context, AnyValue config) { - if (socksServlet != null) socksServlet.init(context, socksServlet.conf == null ? config : socksServlet.conf); - } - - public void setSocksServlet(SocksServlet servlet, AnyValue conf) { - servlet.conf = conf; - if (servlet != null) this.socksServlet = servlet; - } - - // - @Override - public void execute(SocksRequest request, SocksResponse response) throws IOException { - if (request.isHttp()) { - proxyServlet.execute(request, response); - } else { - socksServlet.execute(request, response); - } - } - -} diff --git a/src-plugin/org/redkale/net/socks/SocksProxyServlet.java b/src-plugin/org/redkale/net/socks/SocksProxyServlet.java deleted file mode 100644 index 5c32efa70..000000000 --- a/src-plugin/org/redkale/net/socks/SocksProxyServlet.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.net.socks; - -import org.redkale.net.AsyncConnection; -import org.redkale.util.Utility; -import org.redkale.util.AutoLoad; -import java.io.*; -import java.net.*; -import java.nio.*; -import java.nio.channels.*; - -/** - * 正向代理 - * - * @see http://www.redkale.org - * @author zhangjx - */ -@AutoLoad(false) -public final class SocksProxyServlet extends SocksServlet { - - protected static final byte[] LINE = new byte[]{'\r', '\n'}; - - @Override - public void execute(SocksRequest request, SocksResponse response) throws IOException { - response.skipHeader(); - if ("CONNECT".equalsIgnoreCase(request.getMethod())) { - connect(request, response); - return; - } - String url = request.getRequestURI(); - url = url.substring(url.indexOf("://") + 3); - url = url.substring(url.indexOf('/')); - final ByteBuffer buffer = response.getContext().pollBuffer(); - buffer.put((request.getMethod() + " " + url + " HTTP/1.1\r\n").getBytes()); - for (String header : request.getHeaderNames()) { - if (!header.startsWith("Proxy-")) { - buffer.put((header + ": " + request.getHeader(header) + "\r\n").getBytes()); - } - } - if (request.getHost() != null) { - buffer.put(("Host: " + request.getHost() + "\r\n").getBytes()); - } - if (request.getContentType() != null) { - buffer.put(("Content-Type: " + request.getContentType() + "\r\n").getBytes()); - } - if (request.getContentLength() > 0) { - buffer.put(("Content-Length: " + request.getContentLength() + "\r\n").getBytes()); - } - buffer.put(LINE); - buffer.flip(); - final AsyncConnection remote = AsyncConnection.create("TCP", request.getAsynchronousChannelGroup(), request.getHostSocketAddress(), 6, 6); - remote.write(buffer, null, new CompletionHandler() { - - @Override - public void completed(Integer result, Void attachment) { - if (buffer.hasRemaining()) { - remote.write(buffer, attachment, this); - return; - } - response.getContext().offerBuffer(buffer); - new ProxyCompletionHandler(remote, request, response).completed(0, null); - } - - @Override - public void failed(Throwable exc, Void attachment) { - response.getContext().offerBuffer(buffer); - response.finish(true); - try { - remote.close(); - } catch (IOException ex) { - } - } - }); - } - - private void connect(SocksRequest request, SocksResponse response) throws IOException { - final InetSocketAddress remoteAddress = request.parseSocketAddress(); - final AsyncConnection remote = remoteAddress.getPort() == 443 - ? AsyncConnection.create(Utility.createDefaultSSLSocket(remoteAddress)) : AsyncConnection.create("TCP", request.getAsynchronousChannelGroup(), remoteAddress, 6, 6); - final ByteBuffer buffer0 = response.getContext().pollBuffer(); - buffer0.put("HTTP/1.1 200 Connection established\r\nConnection: close\r\n\r\n".getBytes()); - buffer0.flip(); - response.sendBody(buffer0, null, new CompletionHandler() { - - @Override - public void completed(Integer result, Void attachment) { - new ProxyCompletionHandler(remote, request, response).completed(0, null); - } - - @Override - public void failed(Throwable exc, Void attachment) { - response.finish(true); - try { - remote.close(); - } catch (IOException ex) { - } - } - }); - - } - - private static class ProxyCompletionHandler implements CompletionHandler { - - private AsyncConnection remote; - - private SocksRequest request; - - private SocksResponse response; - - public ProxyCompletionHandler(AsyncConnection remote, SocksRequest request, SocksResponse response) { - this.remote = remote; - this.request = request; - this.response = response; - } - - @Override - public void completed(Integer result0, Void v0) { - final ByteBuffer rbuffer = request.getContext().pollBuffer(); - remote.read(rbuffer, null, new CompletionHandler() { - - @Override - public void completed(Integer result, Void attachment) { - rbuffer.flip(); - CompletionHandler parent = this; - response.sendBody(rbuffer.duplicate().asReadOnlyBuffer(), null, new CompletionHandler() { - - @Override - public void completed(Integer result, Void attachment) { - rbuffer.clear(); - remote.read(rbuffer, attachment, parent); - } - - @Override - public void failed(Throwable exc, Void attachment) { - parent.failed(exc, attachment); - } - }); - } - - @Override - public void failed(Throwable exc, Void attachment) { - response.getContext().offerBuffer(rbuffer); - response.finish(true); - try { - remote.close(); - } catch (IOException ex) { - } - } - }); - - final ByteBuffer qbuffer = request.getContext().pollBuffer(); - request.getChannel().read(qbuffer, null, new CompletionHandler() { - - @Override - public void completed(Integer result, Void attachment) { - qbuffer.flip(); - CompletionHandler parent = this; - remote.write(qbuffer, null, new CompletionHandler() { - - @Override - public void completed(Integer result, Void attachment) { - qbuffer.clear(); - request.getChannel().read(qbuffer, null, parent); - } - - @Override - public void failed(Throwable exc, Void attachment) { - parent.failed(exc, attachment); - } - }); - } - - @Override - public void failed(Throwable exc, Void attachment) { - response.getContext().offerBuffer(qbuffer); - response.finish(true); - try { - remote.close(); - } catch (IOException ex) { - } - } - }); - } - - @Override - public void failed(Throwable exc, Void v) { - response.finish(true); - try { - remote.close(); - } catch (IOException ex) { - } - } - } - -} diff --git a/src-plugin/org/redkale/net/socks/SocksRequest.java b/src-plugin/org/redkale/net/socks/SocksRequest.java deleted file mode 100644 index c906f6449..000000000 --- a/src-plugin/org/redkale/net/socks/SocksRequest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.net.socks; - -import org.redkale.net.AsyncConnection; -import org.redkale.net.http.HttpRequest; -import java.net.*; -import java.nio.*; -import java.nio.channels.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public class SocksRequest extends HttpRequest { - - private boolean http; - - private short requestid; - - protected SocksRequest(SocksContext context) { - super(context, null); - } - - @Override - protected int readHeader(ByteBuffer buffer) { - if (buffer.get(0) > 0x05 && buffer.remaining() > 3) { - this.http = true; - return super.readHeader(buffer); - } - this.http = false; - if (buffer.get() != 0x05) return -1; - if (buffer.get() != 0x01) return -1; - if (buffer.get() != 0x00) return -1; - return 0; - } - - protected InetSocketAddress parseSocketAddress() { - return HttpRequest.parseSocketAddress(getRequestURI()); - } - - public AsynchronousChannelGroup getAsynchronousChannelGroup() { - return ((SocksContext) context).getAsynchronousChannelGroup(); - } - - @Override - protected InetSocketAddress getHostSocketAddress() { - return super.getHostSocketAddress(); - } - - @Override - protected AsyncConnection getChannel() { - return super.getChannel(); - } - - @Override - protected int readBody(ByteBuffer buffer) { - return buffer.remaining(); - } - - @Override - protected void prepare() { - super.prepare(); - } - - @Override - protected void recycle() { - this.requestid = 0; - this.http = false; - super.recycle(); - } - - public short getRequestid() { - return requestid; - } - - public void setRequestid(short requestid) { - this.requestid = requestid; - } - - public boolean isHttp() { - return http; - } - - public void setHttp(boolean http) { - this.http = http; - } - -} diff --git a/src-plugin/org/redkale/net/socks/SocksResponse.java b/src-plugin/org/redkale/net/socks/SocksResponse.java deleted file mode 100644 index 6c46d2190..000000000 --- a/src-plugin/org/redkale/net/socks/SocksResponse.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.net.socks; - -import org.redkale.net.AsyncConnection; -import org.redkale.util.ObjectPool; -import org.redkale.net.http.HttpResponse; -import org.redkale.util.Creator; -import org.redkale.net.Response; -import java.util.concurrent.atomic.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public class SocksResponse extends HttpResponse { - - protected SocksResponse(SocksContext context, SocksRequest request) { - super(context, request, (String[][]) null, (String[][]) null, null); - } - - public static ObjectPool createPool(AtomicLong creatCounter, AtomicLong cycleCounter, int max, Creator creator) { - return new ObjectPool<>(creatCounter, cycleCounter, max, creator, (x) -> ((SocksResponse) x).prepare(), (x) -> ((SocksResponse) x).recycle()); - } - - @Override - public AsyncConnection removeChannel() { - return super.removeChannel(); - } - -} diff --git a/src-plugin/org/redkale/net/socks/SocksRunner.java b/src-plugin/org/redkale/net/socks/SocksRunner.java deleted file mode 100644 index 91523b9d0..000000000 --- a/src-plugin/org/redkale/net/socks/SocksRunner.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.net.socks; - -import org.redkale.net.AsyncConnection; -import java.net.*; -import java.nio.*; -import java.nio.channels.*; -import java.util.logging.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public class SocksRunner implements Runnable { - - private final AsyncConnection channel; - - private final Logger logger; - - private final boolean finest; - - private final SocksContext context; - - private final byte[] bindAddressBytes; - - private ByteBuffer buffer; - - protected boolean closed = false; - - private InetSocketAddress remoteAddress; - - private AsyncConnection remoteChannel; - - public SocksRunner(SocksContext context, AsyncConnection channel, final byte[] bindAddressBytes) { - this.context = context; - this.logger = context.getLogger(); - this.finest = this.context.getLogger().isLoggable(Level.FINEST); - this.channel = channel; - this.buffer = context.pollBuffer(); - this.bindAddressBytes = bindAddressBytes; - } - - @Override - public void run() { - try { - ask(); - } catch (Exception e) { - closeRunner(e); - } - } - - private void ask() { - buffer.putChar((char) 0x0500); - buffer.flip(); - this.channel.write(buffer, null, new CompletionHandler() { - - @Override - public void completed(Integer result, Void attachment) { - if (buffer.hasRemaining()) { - channel.write(buffer, null, this); - return; - } - try { - connect(); - } catch (Exception e) { - closeRunner(e); - } - } - - @Override - public void failed(Throwable exc, Void attachment) { - closeRunner(exc); - } - }); - } - - private void connect() { - buffer.clear(); - this.channel.read(buffer, null, new CompletionHandler() { - - @Override - public void completed(Integer result, Void attachment) { - buffer.flip(); - if (buffer.getChar() != 0x0501) { - if (finest) logger.finest("connect header not 0x0501"); - closeRunner(null); - return; - } - char addrtype = buffer.getChar(); //0x0001 - 4 ; 0x0003 - x ; 0x0004 - 16 - try { - byte[] bytes = new byte[(addrtype == 0x0003) ? (buffer.get() & 0xff) : (addrtype * 4)]; - buffer.get(bytes); - remoteAddress = new InetSocketAddress((addrtype == 0x0003) ? InetAddress.getByName(new String(bytes)) : InetAddress.getByAddress(bytes), buffer.getChar()); - } catch (UnknownHostException e) { - failed(e, attachment); - return; - } - try { - remoteChannel = AsyncConnection.create("TCP", context.getAsynchronousChannelGroup(), remoteAddress, 6, 6); - buffer.clear(); - buffer.putChar((char) 0x0500); - buffer.put((byte) 0x00); //rsv - buffer.put(bindAddressBytes); - buffer.flip(); - final ByteBuffer rbuffer = context.pollBuffer(); - final ByteBuffer wbuffer = context.pollBuffer(); - channel.write(buffer, null, new CompletionHandler() { - - @Override - public void completed(Integer result, Void attachment) { - if (buffer.hasRemaining()) { - channel.write(buffer, null, this); - return; - } - stream(); - } - - @Override - public void failed(Throwable exc, Void attachment) { - context.offerBuffer(rbuffer); - context.offerBuffer(wbuffer); - closeRunner(exc); - } - }); - } catch (Exception e) { - buffer.clear(); - buffer.putChar((char) 0x0504); - if (finest) logger.log(Level.FINEST, remoteAddress + " remote connect error", e); - channel.write(buffer, null, new CompletionHandler() { - - @Override - public void completed(Integer result, Void attachment) { - if (buffer.hasRemaining()) { - channel.write(buffer, null, this); - return; - } - closeRunner(null); - } - - @Override - public void failed(Throwable exc, Void attachment) { - closeRunner(exc); - } - }); - } - } - - @Override - public void failed(Throwable exc, Void attachment) { - closeRunner(exc); - } - }); - } - - private void stream() { - new StreamCompletionHandler(channel, remoteChannel).completed(1, null); - new StreamCompletionHandler(remoteChannel, channel).completed(1, null); - } - - public void closeRunner(final Throwable e) { - if (closed) return; - synchronized (this) { - if (closed) return; - closed = true; - try { - channel.close(); - } catch (Throwable t) { - } - context.offerBuffer(buffer); - buffer = null; - if (e != null && finest) { - logger.log(Level.FINEST, "close socks channel by error", e); - } - } - } - - private class StreamCompletionHandler implements CompletionHandler { - - private final AsyncConnection readconn; - - private final AsyncConnection writeconn; - - private final ByteBuffer rbuffer; - - public StreamCompletionHandler(AsyncConnection conn1, AsyncConnection conn2) { - this.readconn = conn1; - this.writeconn = conn2; - this.rbuffer = context.pollBuffer(); - this.rbuffer.flip(); - } - - @Override - public void completed(Integer result0, Void v0) { - final CompletionHandler self = this; - if (rbuffer.hasRemaining()) { - writeconn.write(rbuffer, null, self); - return; - } - if (result0 < 1) { - self.failed(null, v0); - return; - } - rbuffer.clear(); - readconn.read(rbuffer, null, new CompletionHandler() { - - @Override - public void completed(Integer result, Void attachment) { - if (result < 1) { - self.failed(null, attachment); - return; - } - rbuffer.flip(); - writeconn.write(rbuffer, attachment, self); - } - - @Override - public void failed(Throwable exc, Void attachment) { - self.failed(exc, attachment); - } - }); - } - - @Override - public void failed(Throwable exc, Void v) { - context.offerBuffer(rbuffer); - readconn.dispose(); - writeconn.dispose(); - if (finest) logger.log(Level.FINEST, "StreamCompletionHandler closed", exc); - } - } -} diff --git a/src-plugin/org/redkale/net/socks/SocksServer.java b/src-plugin/org/redkale/net/socks/SocksServer.java deleted file mode 100644 index 1392d3b41..000000000 --- a/src-plugin/org/redkale/net/socks/SocksServer.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.net.socks; - -import org.redkale.util.AnyValue; -import org.redkale.net.Server; -import org.redkale.util.ObjectPool; -import org.redkale.net.Context; -import org.redkale.watch.WatchFactory; -import org.redkale.net.Response; -import java.nio.*; -import java.util.concurrent.atomic.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public final class SocksServer extends Server { - - public SocksServer() { - this(System.currentTimeMillis(), null); - } - - public SocksServer(long serverStartTime, final WatchFactory watch) { - super(serverStartTime, "TCP", new SocksPrepareServlet(), watch); - } - - @Override - public void init(AnyValue config) throws Exception { - super.init(config); - } - - public void addSocksServlet(SocksServlet servlet, AnyValue conf) { - ((SocksPrepareServlet) this.prepare).setSocksServlet(servlet, conf); - } - - @Override - @SuppressWarnings("unchecked") - protected Context createContext() { - if (this.readTimeoutSecond < 1) this.readTimeoutSecond = 6; - if (this.writeTimeoutSecond < 1) this.writeTimeoutSecond = 6; - final int port = this.address.getPort(); - AtomicLong createBufferCounter = watch == null ? new AtomicLong() : watch.createWatchNumber("SOCKS_" + port + ".Buffer.creatCounter"); - AtomicLong cycleBufferCounter = watch == null ? new AtomicLong() : watch.createWatchNumber("SOCKS_" + port + ".Buffer.cycleCounter"); - int rcapacity = Math.max(this.capacity, 8 * 1024); - ObjectPool bufferPool = new ObjectPool<>(createBufferCounter, cycleBufferCounter, this.bufferPoolSize, - (Object... params) -> ByteBuffer.allocateDirect(rcapacity), null, (e) -> { - if (e == null || e.isReadOnly() || e.capacity() != rcapacity) return false; - e.clear(); - return true; - }); - AtomicLong createResponseCounter = watch == null ? new AtomicLong() : watch.createWatchNumber("SOCKS_" + port + ".Response.creatCounter"); - AtomicLong cycleResponseCounter = watch == null ? new AtomicLong() : watch.createWatchNumber("SOCKS_" + port + ".Response.cycleCounter"); - ObjectPool responsePool = SocksResponse.createPool(createResponseCounter, cycleResponseCounter, this.responsePoolSize, null); - SocksContext localcontext = new SocksContext(this.serverStartTime, this.logger, executor, rcapacity, bufferPool, responsePool, - this.maxbody, this.charset, this.address, this.prepare, this.watch, this.readTimeoutSecond, this.writeTimeoutSecond, ""); - responsePool.setCreator((Object... params) -> new SocksResponse(localcontext, new SocksRequest(localcontext))); - return localcontext; - } -} diff --git a/src-plugin/org/redkale/net/socks/SocksServlet.java b/src-plugin/org/redkale/net/socks/SocksServlet.java deleted file mode 100644 index 578b8e43e..000000000 --- a/src-plugin/org/redkale/net/socks/SocksServlet.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.net.socks; - -import org.redkale.util.AnyValue; -import org.redkale.net.Servlet; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public abstract class SocksServlet implements Servlet { - - AnyValue conf; //当前Servlet的配置 - - @Override - public final boolean equals(Object obj) { - return obj != null && obj.getClass() == this.getClass(); - } - - @Override - public final int hashCode() { - return this.getClass().hashCode(); - } -} diff --git a/src-plugin/org/redkale/service/apns/ApnsMessage.java b/src-plugin/org/redkale/service/apns/ApnsMessage.java deleted file mode 100644 index 52d165510..000000000 --- a/src-plugin/org/redkale/service/apns/ApnsMessage.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.service.apns; - -import org.redkale.convert.json.JsonFactory; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public class ApnsMessage { - - public static final int PRIORITY_IMMEDIATELY = 10; - - public static final int PRIORITY_A_TIME = 5; - - private ApnsPayload payload; - - private int expiredate; - - private int priority = PRIORITY_IMMEDIATELY; - - private int identifier; - - private String token; - - public ApnsMessage() { - } - - public ApnsMessage(String token, ApnsPayload payload) { - this(token, payload, 0); - } - - public ApnsMessage(String token, ApnsPayload payload, int expiredate) { - this(token, payload, expiredate, PRIORITY_IMMEDIATELY); - } - - public ApnsMessage(String token, ApnsPayload payload, int expiredate, int priority) { - this.token = token; - this.payload = payload; - this.expiredate = expiredate; - this.priority = priority; - } - - public String getToken() { - return token; - } - - public void setToken(String token) { - this.token = token; - } - - public int getExpiredate() { - return expiredate; - } - - public void setExpiredate(int expiredate) { - this.expiredate = expiredate; - } - - public int getPriority() { - return priority; - } - - public void setPriority(int priority) { - this.priority = priority; - } - - public ApnsPayload getPayload() { - return payload; - } - - public void setPayload(ApnsPayload payload) { - this.payload = payload; - } - - public int getIdentifier() { - return identifier; - } - - public void setIdentifier(int identifier) { - this.identifier = identifier; - } - - @Override - public String toString() { - return JsonFactory.root().getConvert().convertTo(this); - } - -} diff --git a/src-plugin/org/redkale/service/apns/ApnsPayload.java b/src-plugin/org/redkale/service/apns/ApnsPayload.java deleted file mode 100644 index 6873655f1..000000000 --- a/src-plugin/org/redkale/service/apns/ApnsPayload.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.service.apns; - -import org.redkale.convert.json.JsonFactory; -import java.util.*; -import java.util.regex.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public class ApnsPayload { - - private static final Pattern regex = Pattern.compile("\""); - - //----------------------- alert --------------------------------- - private String alertTitle; - - private String alertBody; - - private String alertTitleLocKey; - - private String[] alertTitleLocArgs; - - private String alertActionLocKey; - - private String alertLocKey; - - private String[] alertLocArgs; - - private String alertLaunchImage; - - //-------------------------------------------------------- - private int contentAvailable; - - private String alert; - - private int badge; - - private String sound; - - private final Map attributes = new HashMap<>(); - - public ApnsPayload() { - } - - public ApnsPayload(String alert, int badge) { - this.alert = alert; - this.badge = badge; - } - - public ApnsPayload(String title, String body, int badge) { - this.alertTitle = title; - this.alertBody = body; - this.badge = badge; - } - - public void putAttribute(String name, Object value) { - attributes.put(name, value); - } - - public void removeAttribute(String name) { - attributes.remove(name); - } - - public T getAttribute(String name) { - return (T) attributes.get(name); - } - - public Map getAttributes() { - return attributes; - } - - public void setAttributes(Map map) { - if (map != null) attributes.putAll(map); - } - - @Override - public String toString() { - StringBuilder alertsb = new StringBuilder(); - if (alert != null) { - alertsb.append('"').append(regex.matcher(alert).replaceAll("\\\"")).append('"'); - } else { - alertsb.append('{'); - if (alertTitle != null) { - if (alertsb.length() > 1) alertsb.append(','); - alertsb.append("\"title\":\"").append(regex.matcher(alertTitle).replaceAll("\\\"")).append('"'); - } - if (alertBody != null) { - if (alertsb.length() > 1) alertsb.append(','); - alertsb.append("\"body\":\"").append(regex.matcher(alertBody).replaceAll("\\\"")).append('"'); - } - if (alertTitleLocKey != null) { - if (alertsb.length() > 1) alertsb.append(','); - alertsb.append("\"title-loc-key\":\"").append(regex.matcher(alertTitleLocKey).replaceAll("\\\"")).append('"'); - } - if (alertTitleLocArgs != null && alertTitleLocArgs.length > 0) { - if (alertsb.length() > 1) alertsb.append(','); - alertsb.append("\"title-loc-args\":["); - boolean first = true; - for (String str : alertTitleLocArgs) { - if (!first) alertsb.append(','); - alertsb.append('"').append(regex.matcher(str).replaceAll("\\\"")).append('"'); - first = false; - } - alertsb.append(']'); - } - if (alertActionLocKey != null) { - if (alertsb.length() > 1) alertsb.append(','); - alertsb.append("\"action-loc-key\":\"").append(regex.matcher(alertActionLocKey).replaceAll("\\\"")).append('"'); - } - if (alertLocKey != null) { - if (alertsb.length() > 1) alertsb.append(','); - alertsb.append("\"loc-key\":\"").append(regex.matcher(alertLocKey).replaceAll("\\\"")).append('"'); - } - if (alertLocArgs != null && alertLocArgs.length > 0) { - if (alertsb.length() > 1) alertsb.append(','); - alertsb.append("\"loc-args\":["); - boolean first = true; - for (String str : alertLocArgs) { - if (!first) alertsb.append(','); - alertsb.append('"').append(regex.matcher(str).replaceAll("\\\"")).append('"'); - first = false; - } - alertsb.append(']'); - } - if (alertLaunchImage != null) { - if (alertsb.length() > 1) alertsb.append(','); - alertsb.append("\"launch-image\":\"").append(regex.matcher(alertLaunchImage).replaceAll("\\\"")).append('"'); - } - alertsb.append('}'); - } - final StringBuilder sb = new StringBuilder(); - sb.append("{\"aps\":{\"alert\":").append(alertsb); - if (badge > 0) sb.append(",\"badge\":").append(badge); - if (contentAvailable > 0) sb.append(",\"content-available\":").append(contentAvailable); - if (sound != null) sb.append(",\"sound\":\"").append(sound).append('"'); - sb.append("}"); - if (attributes.isEmpty()) { - sb.append('}'); - } else { - sb.append(',').append(JsonFactory.root().getConvert().convertTo(attributes).substring(1)); - } - return sb.toString(); - } - - public String getAlertTitle() { - return alertTitle; - } - - public void setAlertTitle(String alertTitle) { - this.alertTitle = alertTitle; - } - - public String getAlertBody() { - return alertBody; - } - - public void setAlertBody(String alertBody) { - this.alertBody = alertBody; - } - - public String getAlertTitleLocKey() { - return alertTitleLocKey; - } - - public void setAlertTitleLocKey(String alertTitleLocKey) { - this.alertTitleLocKey = alertTitleLocKey; - } - - public String[] getAlertTitleLocArgs() { - return alertTitleLocArgs; - } - - public void setAlertTitleLocArgs(String[] alertTitleLocArgs) { - this.alertTitleLocArgs = alertTitleLocArgs; - } - - public String getAlertActionLocKey() { - return alertActionLocKey; - } - - public void setAlertActionLocKey(String alertActionLocKey) { - this.alertActionLocKey = alertActionLocKey; - } - - public String getAlertLocKey() { - return alertLocKey; - } - - public void setAlertLocKey(String alertLocKey) { - this.alertLocKey = alertLocKey; - } - - public String[] getAlertLocArgs() { - return alertLocArgs; - } - - public void setAlertLocArgs(String[] alertLocArgs) { - this.alertLocArgs = alertLocArgs; - } - - public String getAlertLaunchImage() { - return alertLaunchImage; - } - - public void setAlertLaunchImage(String alertLaunchImage) { - this.alertLaunchImage = alertLaunchImage; - } - - public int getContentAvailable() { - return contentAvailable; - } - - public void setContentAvailable(int contentAvailable) { - this.contentAvailable = contentAvailable; - } - - public String getAlert() { - return alert; - } - - public void setAlert(String alert) { - this.alert = alert; - } - - public int getBadge() { - return badge; - } - - public void setBadge(int badge) { - this.badge = badge; - } - - public String getSound() { - return sound; - } - - public void setSound(String sound) { - this.sound = sound; - } - -} diff --git a/src-plugin/org/redkale/service/apns/ApnsService.java b/src-plugin/org/redkale/service/apns/ApnsService.java deleted file mode 100644 index 0707586a7..000000000 --- a/src-plugin/org/redkale/service/apns/ApnsService.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.service.apns; - -import org.redkale.util.AnyValue; -import org.redkale.util.Utility; -import org.redkale.convert.json.JsonConvert; -import org.redkale.util.AutoLoad; -import org.redkale.service.LocalService; -import org.redkale.service.Service; -import java.io.*; -import java.net.*; -import java.nio.*; -import java.nio.charset.*; -import java.security.*; -import java.util.concurrent.*; -import java.util.logging.*; -import javax.annotation.*; -import javax.net.ssl.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -@AutoLoad(false) -@LocalService -public class ApnsService implements Service { - - private static final Charset UTF8 = Charset.forName("UTF-8"); - - protected final Logger logger = Logger.getLogger(this.getClass().getSimpleName()); - - @Resource - protected JsonConvert convert; - - @Resource(name = "property.apns.certpwd") - protected String apnscertpwd = "1"; //证书的密码 - - @Resource(name = "property.apns.certpath") //用来加载证书用 - protected String apnscertpath = "apnspushdev_cert.p12"; - - @Resource(name = "property.apns.pushaddr") // - protected String apnspushaddr = "gateway.sandbox.push.apple.com"; - - @Resource(name = "property.apns.pushport") // - protected int apnspushport = 2195; - - @Resource(name = "property.apns.buffersize") // - protected int apnsbuffersize = 4096; - - private boolean inited = false; - - private final CountDownLatch cdl = new CountDownLatch(1); - - private SSLSocketFactory sslFactory; - - @Override - public void init(AnyValue conf) { - new Thread() { - { - setDaemon(true); - setPriority(Thread.MAX_PRIORITY); - } - - @Override - public void run() { - try { - final String path = "/" + this.getClass().getPackage().getName().replace('.', '/') + "/" + apnscertpath; - KeyStore ks = KeyStore.getInstance("PKCS12"); - InputStream in = ApnsService.class.getResourceAsStream(path); - KeyManagerFactory kf = null; - if (in != null) { - ks.load(in, apnscertpwd.toCharArray()); - in.close(); - kf = KeyManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); - kf.init(ks, apnscertpwd.toCharArray()); - } - - TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); - tmf.init((KeyStore) null); - SSLContext context = SSLContext.getInstance("TLS"); - context.init(kf == null ? new KeyManager[0] : kf.getKeyManagers(), tmf.getTrustManagers(), null); - ApnsService.this.sslFactory = context.getSocketFactory(); - } catch (Exception e) { - logger.log(Level.SEVERE, this.getClass().getSimpleName() + " init SSLContext error", e); - } finally { - inited = true; - cdl.countDown(); - } - } - }.start(); - } - - @Override - public void destroy(AnyValue conf) { - } - - private Socket getPushSocket() throws IOException { - if (!this.inited) { - try { - cdl.await(); - } catch (InterruptedException e) { - } - } - Socket pushSocket = sslFactory.createSocket(apnspushaddr, apnspushport); - pushSocket.setTcpNoDelay(true); - return pushSocket; - } - - public void pushApnsMessage(ApnsMessage message) throws IOException { - final byte[] tokens = Utility.hexToBin(message.getToken().replaceAll("\\s+", "")); - ByteBuffer buffer = ByteBuffer.allocate(apnsbuffersize); - buffer.put((byte) 2); //固定命令号 - buffer.putInt(0); //下面数据的长度 - - buffer.put((byte) 1); //token - buffer.putShort((short) tokens.length); - buffer.put(tokens); - - buffer.put((byte) 2); //payload - final byte[] payload = message.getPayload().toString().getBytes(UTF8); - buffer.putShort((short) payload.length); - buffer.put(payload); - - if (message.getIdentifier() > 0) { - buffer.put((byte) 3); //Notification identifier - buffer.putShort((short) 4); - buffer.putInt(message.getIdentifier()); - } - if (message.getExpiredate() > 0) { - buffer.put((byte) 4); //Expiration date - buffer.putShort((short) 4); - buffer.putInt(message.getExpiredate()); - } - buffer.put((byte) 5); //Priority - buffer.putShort((short) 1); - buffer.put((byte) message.getPriority()); - - final int pos = buffer.position(); - buffer.position(1); - buffer.putInt(pos - 5); - buffer.position(pos); - buffer.flip(); - - Socket socket = getPushSocket(); - socket.getOutputStream().write(buffer.array(), 0, buffer.remaining()); - socket.close(); - } - -// public static void main(String[] args) throws Exception { -// ApnsService service = new ApnsService(); -// service.convert = JsonFactory.root().getConvert(); -// service.init(null); -// -// final String token = "01727b19 b9f8abf4 0891e31d 3446479d a43902e1 819edc44 a073d951 b8b7db90"; -// ApnsPayload payload = new ApnsPayload("您有新的消息", "这是消息内容", 1); -// System.out.println(payload); -// service.pushApnsMessage(new ApnsMessage(token, payload)); -// } - -} diff --git a/src-plugin/org/redkale/service/weixin/WeiXinMPService.java b/src-plugin/org/redkale/service/weixin/WeiXinMPService.java deleted file mode 100644 index 6ecb3d3b1..000000000 --- a/src-plugin/org/redkale/service/weixin/WeiXinMPService.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.service.weixin; - -import org.redkale.util.Utility; -import org.redkale.convert.json.JsonConvert; -import org.redkale.service.RetResult; -import org.redkale.util.AutoLoad; -import org.redkale.service.LocalService; -import org.redkale.service.Service; -import static org.redkale.convert.json.JsonConvert.TYPE_MAP_STRING_STRING; -import static org.redkale.util.Utility.getHttpContent; -import java.io.*; -import java.security.*; -import java.util.*; -import java.util.logging.*; -import javax.annotation.*; - -/** - * 微信服务号Service - * - * @see http://www.redkale.org - * @author zhangjx - */ -@AutoLoad(false) -@LocalService -public class WeiXinMPService implements Service { - - protected final Logger logger = Logger.getLogger(this.getClass().getSimpleName()); - - private final boolean finest = logger.isLoggable(Level.FINEST); - - private final boolean finer = logger.isLoggable(Level.FINER); - - protected final Map mpsecrets = new HashMap<>(); - - @Resource - protected JsonConvert convert; - - // http://m.xxx.com/pipes/wx/verifymp - @Resource(name = "property.wxmp.token") - protected String mptoken = ""; - - @Resource(name = "property.wxmp.corpid") - protected String mpcorpid = "wxYYYYYYYYYYYYYY"; - - @Resource(name = "property.wxmp.aeskey") - protected String mpaeskey = ""; - - public WeiXinMPService() { - // mpsecrets.put("wxYYYYYYYYYYYYYYYYYY", "xxxxxxxxxxxxxxxxxxxxxxxxxxx"); - } - - //-----------------------------------微信服务号接口---------------------------------------------------------- - public RetResult getMPWxunionidByCode(String appid, String code) { - try { - Map wxmap = getMPUserTokenByCode(appid, code); - final String unionid = wxmap.get("unionid"); - if (unionid != null && !unionid.isEmpty()) return new RetResult<>(unionid); - return new RetResult<>(1011002); - } catch (IOException e) { - return new RetResult<>(1011001); - } - } - - public Map getMPUserTokenByCode(String appid, String code) throws IOException { - String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appid + "&secret=" + mpsecrets.get(appid) + "&code=" + code + "&grant_type=authorization_code"; - String json = getHttpContent(url); - if (finest) logger.finest(url + "--->" + json); - Map jsonmap = convert.convertFrom(TYPE_MAP_STRING_STRING, json); - return getMPUserTokenByOpenid(jsonmap.get("access_token"), jsonmap.get("openid")); - } - - public Map getMPUserTokenByOpenid(String access_token, String openid) throws IOException { - String url = "https://api.weixin.qq.com/sns/userinfo?access_token=" + access_token + "&openid=" + openid; - String json = getHttpContent(url); - if (finest) logger.finest(url + "--->" + json); - Map jsonmap = convert.convertFrom(TYPE_MAP_STRING_STRING, json.replaceFirst("\\[.*\\]", "null")); - return jsonmap; - } - - public String verifyMPURL(String msgSignature, String timeStamp, String nonce, String echoStr) { - String signature = sha1(mptoken, timeStamp, nonce); - if (!signature.equals(msgSignature)) throw new RuntimeException("signature verification error"); - return echoStr; - } - - /** - * 用SHA1算法生成安全签名 - *

- * @param strings - * @return 安全签名 - */ - protected static String sha1(String... strings) { - try { - Arrays.sort(strings); - MessageDigest md = MessageDigest.getInstance("SHA-1"); - for (String s : strings) md.update(s.getBytes()); - return Utility.binToHexString(md.digest()); - } catch (Exception e) { - throw new RuntimeException("SHA encryption to generate signature failure", e); - } - } -} diff --git a/src-plugin/org/redkale/service/weixin/WeiXinPayResult.java b/src-plugin/org/redkale/service/weixin/WeiXinPayResult.java deleted file mode 100644 index 142556fae..000000000 --- a/src-plugin/org/redkale/service/weixin/WeiXinPayResult.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.service.weixin; - -import org.redkale.service.RetResult; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -public class WeiXinPayResult extends RetResult { - - //待支付 - public static final short PAYSTATUS_UNPAY = 10; - - //已支付 - public static final short PAYSTATUS_PAYOK = 30; - - private long orderid; - - private long payid; - - private long payedmoney; - - private short paystatus; - - public WeiXinPayResult() { - } - - public WeiXinPayResult(int retcode) { - super(retcode); - } - - public WeiXinPayResult(long orderid, long payid, short paystatus, long payedmoney, String resultcontent) { - this.orderid = orderid; - this.payid = payid; - this.paystatus = paystatus; - this.payedmoney = payedmoney; - this.setResult(resultcontent); - } - - public long getOrderid() { - return orderid; - } - - public void setOrderid(long orderid) { - this.orderid = orderid; - } - - public long getPayid() { - return payid; - } - - public void setPayid(long payid) { - this.payid = payid; - } - - public long getPayedmoney() { - return payedmoney; - } - - public void setPayedmoney(long payedmoney) { - this.payedmoney = payedmoney; - } - - public short getPaystatus() { - return paystatus; - } - - public void setPaystatus(short paystatus) { - this.paystatus = paystatus; - } - -} diff --git a/src-plugin/org/redkale/service/weixin/WeiXinPayService.java b/src-plugin/org/redkale/service/weixin/WeiXinPayService.java deleted file mode 100644 index 2614f2bf6..000000000 --- a/src-plugin/org/redkale/service/weixin/WeiXinPayService.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.service.weixin; - -import org.redkale.util.Utility; -import org.redkale.convert.json.JsonConvert; -import org.redkale.service.RetResult; -import org.redkale.util.AutoLoad; -import org.redkale.service.LocalService; -import org.redkale.service.Service; -import static org.redkale.service.weixin.WeiXinPayResult.*; -import java.security.*; -import java.text.*; -import java.util.*; -import java.util.logging.*; -import java.util.regex.*; -import javax.annotation.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -@AutoLoad(false) -@LocalService -public class WeiXinPayService implements Service { - - private static final DateFormat FORMAT = new SimpleDateFormat("yyyyMMddHHmmss"); - - private static final Pattern PAYXML = Pattern.compile("<([^/>]+)>(.+)"); // "<([^/>]+)>" - - public static final int PAY_WX_ERROR = 4012101;//微信支付失败 - - public static final int PAY_FALSIFY_ORDER = 4012017;//交易签名被篡改 - - public static final int PAY_STATUS_ERROR = 4012018;//订单或者支付状态不正确 - - protected final Logger logger = Logger.getLogger(this.getClass().getSimpleName()); - - protected final boolean fine = logger.isLoggable(Level.FINE); - - protected final boolean finer = logger.isLoggable(Level.FINER); - - protected final boolean finest = logger.isLoggable(Level.FINEST); - - @Resource(name = "property.wxpay.appid") //公众账号ID - protected String wxpayappid = "wxYYYYYYYYYYYY"; - - @Resource(name = "property.wxpay.mchid") //商户ID - protected String wxpaymchid = "xxxxxxxxxxx"; - - @Resource(name = "property.wxpay.sdbmchid") //子商户ID,受理模式必填 - protected String wxpaysdbmchid = ""; - - @Resource(name = "property.wxpay.key") //签名算法需要用到的秘钥 - protected String wxpaykey = "##########################"; - - @Resource(name = "property.wxpay.certpwd") - protected String wxpaycertpwd = "xxxxxxxxxx"; //HTTP证书的密码,默认等于MCHID - - @Resource(name = "property.wxpay.certpath") //HTTP证书在服务器中的路径,用来加载证书用 - protected String wxpaycertpath = "apiclient_cert.p12"; - - @Resource - protected JsonConvert convert; - - /** - * - * + " - * + " - * + " - * + " - * + " - * + " - * + " - * + " - * + " - *

- * @param orderid - * @param payid - * @param orderpayid - * @param paymoney - * @param clientAddr - * @param notifyurl - * @param map - * @return - */ - public RetResult> paying(long orderid, long payid, long orderpayid, long paymoney, String clientAddr, String notifyurl, Map map) { - RetResult result = null; - try { - if (!(map instanceof SortedMap)) map = new TreeMap<>(map); - map.put("appid", wxpayappid); - map.put("mch_id", wxpaymchid); - map.put("nonce_str", Long.toHexString(System.currentTimeMillis()) + Long.toHexString(System.nanoTime())); - map.putIfAbsent("body", "服务"); - map.put("attach", "" + payid); - map.put("out_trade_no", "" + orderpayid); - map.put("total_fee", "" + paymoney); - map.put("spbill_create_ip", clientAddr); - synchronized (FORMAT) { - map.put("time_expire", FORMAT.format(new Date(System.currentTimeMillis() + 10 * 60 * 60 * 1000))); - } - map.put("notify_url", notifyurl); - { - final StringBuilder sb = new StringBuilder(); - map.forEach((x, y) -> sb.append(x).append('=').append(y).append('&')); - sb.append("key=").append(wxpaykey); - map.put("sign", Utility.binToHexString(MessageDigest.getInstance("MD5").digest(sb.toString().getBytes())).toUpperCase()); - } - if (finest) logger.finest("weixinpaying2: " + orderid + " -> unifiedorder.map =" + map); - Map wxresult = formatXMLToMap(Utility.postHttpContent("https://api.mch.weixin.qq.com/pay/unifiedorder", formatMapToXML(map))); - if (finest) logger.finest("weixinpaying3: " + orderid + " -> unifiedorder.callback =" + wxresult); - if (!"SUCCESS".equals(wxresult.get("return_code"))) return new RetResult<>(PAY_WX_ERROR); - if (!checkSign(wxresult)) return new RetResult(PAY_FALSIFY_ORDER); - /** - * "appId" : "wx2421b1c4370ec43b", //公众号名称,由商户传入 "timeStamp":" 1395712654", //时间戳,自1970年以来的秒数 "nonceStr" : "e61463f8efa94090b1f366cccfbbb444", //随机串 "package" : - * "prepay_id=u802345jgfjsdfgsdg888", "signType" : "MD5", //微信签名方式: "paySign" : "70EA570631E4BB79628FBCA90534C63FF7FADD89" //微信签名 - */ - Map rs = new TreeMap<>(); - rs.put("appId", this.wxpayappid); - rs.put("timeStamp", Long.toString(System.currentTimeMillis() / 1000)); - rs.put("nonceStr", Long.toHexString(System.currentTimeMillis()) + Long.toHexString(System.nanoTime())); - rs.put("package", "prepay_id=" + wxresult.get("prepay_id")); - rs.put("signType", "MD5"); - { - final StringBuilder sb2 = new StringBuilder(); - rs.forEach((x, y) -> sb2.append(x).append('=').append(y).append('&')); - sb2.append("key=").append(wxpaykey); - rs.put("paySign", Utility.binToHexString(MessageDigest.getInstance("MD5").digest(sb2.toString().getBytes())).toUpperCase()); - } - if (finest) logger.finest("weixinpaying4: " + orderid + " -> unifiedorder.result =" + rs); - RetResult rr = new RetResult(rs); - rr.setRetinfo("" + orderpayid); - return rr; - } catch (Exception e) { - logger.log(Level.WARNING, "paying error.", e); - } - return result; - } - - public RetResult closepay(long orderpayid) { - RetResult result = null; - try { - Map map = new TreeMap<>(); - map.put("appid", wxpayappid); - map.put("mch_id", wxpaymchid); - map.put("nonce_str", Long.toHexString(System.currentTimeMillis()) + Long.toHexString(System.nanoTime())); - map.put("out_trade_no", "" + orderpayid); - { - final StringBuilder sb = new StringBuilder(); - map.forEach((x, y) -> sb.append(x).append('=').append(y).append('&')); - sb.append("key=").append(wxpaykey); - map.put("sign", Utility.binToHexString(MessageDigest.getInstance("MD5").digest(sb.toString().getBytes())).toUpperCase()); - } - if (finest) logger.finest("weixinclosepay2: " + orderpayid + " -> closeorder.map =" + map); - Map wxresult = formatXMLToMap(Utility.postHttpContent("https://api.mch.weixin.qq.com/pay/closeorder", formatMapToXML(map))); - if (finest) logger.finest("weixinclosepay3: " + orderpayid + " -> closeorder.callback =" + wxresult); - if (!"SUCCESS".equals(wxresult.get("return_code"))) return new RetResult<>(PAY_WX_ERROR); - if (!checkSign(wxresult)) return new RetResult(PAY_FALSIFY_ORDER); - return new RetResult(wxresult); - } catch (Exception e) { - logger.log(Level.WARNING, "closepay error: " + orderpayid, e); - } - return result; - } - - public WeiXinPayResult checkPay(long orderid, long orderpayid) { - WeiXinPayResult result = new WeiXinPayResult(PAY_STATUS_ERROR); - try { - Map map = new TreeMap<>(); - map.put("appid", wxpayappid); - map.put("mch_id", wxpaymchid); - map.put("out_trade_no", "" + orderpayid); - map.put("nonce_str", Long.toHexString(System.currentTimeMillis()) + Long.toHexString(System.nanoTime())); - { - final StringBuilder sb = new StringBuilder(); - map.forEach((x, y) -> sb.append(x).append('=').append(y).append('&')); - sb.append("key=").append(wxpaykey); - map.put("sign", Utility.binToHexString(MessageDigest.getInstance("MD5").digest(sb.toString().getBytes())).toUpperCase()); - } - Map wxresult = formatXMLToMap(Utility.postHttpContent("https://api.mch.weixin.qq.com/pay/orderquery", formatMapToXML(map))); - return callbackPay(wxresult); - } catch (Exception e) { - logger.log(Level.FINER, "check weixinpay[" + orderid + "] except", e); - return result; - } - } - - /** - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * 10 - * - * - * - *

- * @param map - * @return - */ - public WeiXinPayResult callbackPay(Map map) { - if (!"SUCCESS".equals(map.get("return_code"))) return new WeiXinPayResult(PAY_WX_ERROR); - if (!(map instanceof SortedMap)) map = new TreeMap<>(map); - if (!checkSign(map)) return new WeiXinPayResult(PAY_FALSIFY_ORDER); - String state = map.get("trade_state"); - if (state == null && "SUCCESS".equals(map.get("result_code")) && Long.parseLong(map.get("total_fee")) > 0) { - state = "SUCCESS"; - } - short paystatus = "SUCCESS".equals(state) ? PAYSTATUS_PAYOK : PAYSTATUS_UNPAY; - return new WeiXinPayResult(Long.parseLong(map.get("out_trade_no")), Long.parseLong(map.get("attach")), paystatus, Long.parseLong(map.get("total_fee")), convert.convertTo(map)); - } - - protected static String formatMapToXML(final Map map) { - final StringBuilder sb = new StringBuilder(); - sb.append(""); - map.forEach((x, y) -> sb.append('<').append(x).append('>').append(y.replace("<", "<").replace(">", ">").replace("&", "&")).append("')); - sb.append(""); - return sb.toString(); - } - - protected boolean checkSign(Map map) { - if (!(map instanceof SortedMap)) map = new TreeMap<>(map); - String sign = map.remove("sign"); - final StringBuilder sb = new StringBuilder(); - map.forEach((x, y) -> sb.append(x).append('=').append(y).append('&')); - sb.append("key=").append(wxpaykey); - try { - return sign.equals(Utility.binToHexString(MessageDigest.getInstance("MD5").digest(sb.toString().getBytes())).toUpperCase()); - } catch (Exception e) { - return false; - } - } - - public static Map formatXMLToMap(final String xml) { - Map map = new TreeMap<>(); - Matcher m = PAYXML.matcher(xml.substring(xml.indexOf('>') + 1)); - while (m.find()) { - String val = m.group(2); - if (val.startsWith(" text; - - private String touser = "@all"; - - private String toparty; - - private String totag; - - private String safe; - - private Supplier contentSupplier; - - public WeiXinQYMessage() { - } - - public WeiXinQYMessage(String agentid, String text) { - this.agentid = agentid; - setTextMessage(text); - } - - public WeiXinQYMessage(String agentid, Supplier contentSupplier) { - this.agentid = agentid; - this.contentSupplier = contentSupplier; - } - - public final void setTextMessage(String content) { - if (text == null) text = new HashMap<>(); - text.put("content", content); - } - - public void supplyContent() { - if (contentSupplier != null) setTextMessage(contentSupplier.get()); - } - - public String getAgentid() { - return agentid; - } - - public void setAgentid(String agentid) { - this.agentid = agentid; - } - - public String getMsgtype() { - return msgtype; - } - - public void setMsgtype(String msgtype) { - this.msgtype = msgtype; - } - - public Map getText() { - return text; - } - - public void setText(Map text) { - this.text = text; - } - - public String getTouser() { - return touser; - } - - public void setTouser(String touser) { - this.touser = touser; - } - - public String getToparty() { - return toparty; - } - - public void setToparty(String toparty) { - this.toparty = toparty; - } - - public String getTotag() { - return totag; - } - - public void setTotag(String totag) { - this.totag = totag; - } - - public String getSafe() { - return safe; - } - - public void setSafe(String safe) { - this.safe = safe; - } - - @Override - public String toString() { - return JsonFactory.root().getConvert().convertTo(this); - } -} diff --git a/src-plugin/org/redkale/service/weixin/WeiXinQYService.java b/src-plugin/org/redkale/service/weixin/WeiXinQYService.java deleted file mode 100644 index e99b8772c..000000000 --- a/src-plugin/org/redkale/service/weixin/WeiXinQYService.java +++ /dev/null @@ -1,321 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.service.weixin; - -import org.redkale.util.ByteArray; -import org.redkale.util.TypeToken; -import org.redkale.util.Utility; -import org.redkale.convert.json.JsonConvert; -import org.redkale.util.AutoLoad; -import org.redkale.service.LocalService; -import org.redkale.service.Service; -import org.redkale.net.WorkThread; -import static org.redkale.util.Utility.*; -import java.io.*; -import java.lang.reflect.*; -import java.nio.charset.*; -import java.security.*; -import java.util.*; -import java.util.function.*; -import java.util.logging.*; -import javax.annotation.*; -import javax.crypto.*; -import javax.crypto.spec.*; - -/** - * - * @see http://www.redkale.org - * @author zhangjx - */ -@AutoLoad(false) -@LocalService -public class WeiXinQYService implements Service { - - protected final Logger logger = Logger.getLogger(this.getClass().getSimpleName()); - - private final boolean finest = logger.isLoggable(Level.FINEST); - - private final boolean finer = logger.isLoggable(Level.FINER); - - private static class Token { - - public String token; - - public long expires = 7100000; - - public long accesstime; - } - - private static final String BASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - - private static final Charset CHARSET = Charset.forName("UTF-8"); - - private static final Random RANDOM = new Random(); - - protected static final Type MAPTYPE = new TypeToken>() { - }.getType(); - - @Resource - protected JsonConvert convert; - - //------------------------------------------------------------------------------------------------------ - // http://oa.xxxx.com/pipes/wx/verifyqy - @Resource(name = "property.wxqy.token") - protected String qytoken = ""; - - @Resource(name = "property.wxqy.corpid") - protected String qycorpid = "wxYYYYYYYYYYYYYYYY"; - - @Resource(name = "property.wxqy.aeskey") - protected String qyaeskey = ""; - - @Resource(name = "property.wxqy.secret") - private String qysecret = "#########################"; - - private SecretKeySpec qykeyspec; - - private IvParameterSpec qyivspec; - - private final Token qyAccessToken = new Token(); - - //------------------------------------------------------------------------------------------------------ - public WeiXinQYService() { - } - -// public static void main(String[] args) throws Exception { -// WeiXinQYService service = Application.singleton(WeiXinQYService.class); -// -// WeiXinQYMessage message = new WeiXinQYMessage(); -// message.setTextMessage("【测试】duang!"); -// message.setAgentid("2"); -// service.sendQYMessage(message); -// } - - //-----------------------------------微信企业号接口---------------------------------------------------------- - public Map getQYUserCode(String code, String agentid) throws IOException { - String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=" + getQYAccessToken() + "&code=" + code + "&agentid=" + agentid; - String json = getHttpContent(url); - if (finest) logger.finest(url + "--->" + json); - return convert.convertFrom(MAPTYPE, json); - } - - public void sendQYTextMessage(String agentid, String message) { - sendQYMessage(new WeiXinQYMessage(agentid, message)); - } - - public void sendQYTextMessage(String agentid, Supplier contentSupplier) { - sendQYMessage(new WeiXinQYMessage(agentid, contentSupplier)); - } - - public void sendQYMessage(WeiXinQYMessage message) { - submit(() -> { - String result = null; - try { - message.supplyContent(); - String url = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=" + getQYAccessToken(); - result = postHttpContent(url, convert.convertTo(message)); - if (finest) logger.finest("sendQYMessage ok: " + message + " -> " + result); - } catch (Exception e) { - logger.log(Level.WARNING, "sendQYMessage error: " + message + " -> " + result, e); - } - }); - } - - public String verifyQYURL(String msgSignature, String timeStamp, String nonce, String echoStr) { - String signature = sha1(qytoken, timeStamp, nonce, echoStr); - if (!signature.equals(msgSignature)) throw new RuntimeException("signature verification error"); - return decryptQY(echoStr); - } - - protected String getQYAccessToken() throws IOException { - if (qyAccessToken.accesstime < System.currentTimeMillis() - qyAccessToken.expires) qyAccessToken.token = null; - if (qyAccessToken.token == null) { - String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" + qycorpid + "&corpsecret=" + qysecret; - String json = getHttpContent(url); - if (finest) logger.finest(url + "--->" + json); - Map jsonmap = convert.convertFrom(MAPTYPE, json); - qyAccessToken.accesstime = System.currentTimeMillis(); - qyAccessToken.token = jsonmap.get("access_token"); - String exp = jsonmap.get("expires_in"); - if (exp != null) qyAccessToken.expires = (Integer.parseInt(exp) - 100) * 1000; - } - return qyAccessToken.token; - } - - /** - * 将公众平台回复用户的消息加密打包. - *

    - *
  1. 对要发送的消息进行AES-CBC加密
  2. - *
  3. 生成安全签名
  4. - *
  5. 将消息密文和安全签名打包成xml格式
  6. - *
- *

- * @param replyMsg 公众平台待回复用户的消息,xml格式的字符串 - * @param timeStamp 时间戳,可以自己生成,也可以用URL参数的timestamp - * @param nonce 随机串,可以自己生成,也可以用URL参数的nonce - *

- * @return 加密后的可以直接回复用户的密文,包括msg_signature, timestamp, nonce, encrypt的xml格式的字符串 - */ - protected String encryptQYMessage(String replyMsg, String timeStamp, String nonce) { - // 加密 - String encrypt = encryptQY(random16String(), replyMsg); - - // 生成安全签名 - if (timeStamp == null || timeStamp.isEmpty()) timeStamp = Long.toString(System.currentTimeMillis()); - String signature = sha1(qytoken, timeStamp, nonce, encrypt); - - // System.out.println("发送给平台的签名是: " + signature[1].toString()); - // 生成发送的xml - return "\n\n" - + "\n" - + "" + timeStamp + "\n" - + "\n"; - } - - protected String decryptQYMessage(String msgSignature, String timeStamp, String nonce, String postData) { - // 密钥,公众账号的app secret - // 提取密文 - String encrypt = postData.substring(postData.indexOf("")); - // 验证安全签名 - if (!sha1(qytoken, timeStamp, nonce, encrypt).equals(msgSignature)) throw new RuntimeException("signature verification error"); - return decryptQY(encrypt); - } - - /** - * 对明文进行加密. - *

- * @param randomStr - * @param text 需要加密的明文 - * @return 加密后base64编码的字符串 - */ - protected String encryptQY(String randomStr, String text) { - ByteArray bytes = new ByteArray(); - byte[] randomStrBytes = randomStr.getBytes(CHARSET); - byte[] textBytes = text.getBytes(CHARSET); - byte[] corpidBytes = qycorpid.getBytes(CHARSET); - - // randomStr + networkBytesOrder + text + qycorpid - bytes.add(randomStrBytes); - bytes.addInt(textBytes.length); - bytes.add(textBytes); - bytes.add(corpidBytes); - - // ... + pad: 使用自定义的填充方式对明文进行补位填充 - byte[] padBytes = encodePKCS7(bytes.count()); - bytes.add(padBytes); - - // 获得最终的字节流, 未加密 - try { - // 加密 - byte[] encrypted = createQYCipher(Cipher.ENCRYPT_MODE).doFinal(bytes.directBytes(), 0, bytes.count()); - // 使用BASE64对加密后的字符串进行编码 - return Base64.getEncoder().encodeToString(encrypted); - } catch (Exception e) { - throw new RuntimeException("AES加密失败", e); - } - } - - protected String decryptQY(String text) { - byte[] original; - try { - // 使用BASE64对密文进行解码 - original = createQYCipher(Cipher.DECRYPT_MODE).doFinal(Base64.getDecoder().decode(text)); - } catch (Exception e) { - throw new RuntimeException("AES解密失败", e); - } - try { - // 去除补位字符 - byte[] bytes = decodePKCS7(original); - // 分离16位随机字符串,网络字节序和corpid - int xmlLength = (bytes[16] & 0xFF) << 24 | (bytes[17] & 0xFF) << 16 | (bytes[18] & 0xFF) << 8 | bytes[19] & 0xFF; - if (!qycorpid.equals(new String(bytes, 20 + xmlLength, bytes.length - 20 - xmlLength, CHARSET))) { - throw new RuntimeException("corpid校验失败"); - } - return new String(bytes, 20, xmlLength, CHARSET); - } catch (RuntimeException e) { - if (e.getMessage().contains("corpid")) throw e; - throw new RuntimeException("解密后得到的buffer非法", e); - } - } - - protected Cipher createQYCipher(int mode) throws Exception { - Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); //AES192、256位加密解密 需要将新版 local_policy.jar、US_export_policy.jar两个文件覆盖到 ${JDK_HOME}/jre/lib/security/下 - if (qykeyspec == null) { - byte[] aeskeyBytes = Base64.getDecoder().decode(qyaeskey + "="); - qykeyspec = new SecretKeySpec(aeskeyBytes, "AES"); - qyivspec = new IvParameterSpec(aeskeyBytes, 0, 16); - } - cipher.init(mode, qykeyspec, qyivspec); - return cipher; - } - - protected void submit(Runnable runner) { - Thread thread = Thread.currentThread(); - if (thread instanceof WorkThread) { - ((WorkThread) thread).submit(runner); - return; - } - runner.run(); - } - - //-----------------------------------通用接口---------------------------------------------------------- - // 随机生成16位字符串 - protected static String random16String() { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < 16; i++) { - sb.append(BASE.charAt(RANDOM.nextInt(BASE.length()))); - } - return sb.toString(); - } - - /** - * 用SHA1算法生成安全签名 - *

- * @param strings - * @return 安全签名 - */ - protected static String sha1(String... strings) { - try { - Arrays.sort(strings); - MessageDigest md = MessageDigest.getInstance("SHA-1"); - for (String s : strings) md.update(s.getBytes()); - return Utility.binToHexString(md.digest()); - } catch (Exception e) { - throw new RuntimeException("SHA encryption to generate signature failure", e); - } - } - - /** - * 获得对明文进行补位填充的字节. - *

- * @param count 需要进行填充补位操作的明文字节个数 - * @return 补齐用的字节数组 - */ - private static byte[] encodePKCS7(int count) { - // 计算需要填充的位数 - int amountToPad = 32 - (count % 32); - if (amountToPad == 0) amountToPad = 32; - // 获得补位所用的字符 - char padChr = (char) (byte) (amountToPad & 0xFF); - StringBuilder tmp = new StringBuilder(); - for (int index = 0; index < amountToPad; index++) { - tmp.append(padChr); - } - return tmp.toString().getBytes(CHARSET); - } - - /** - * 删除解密后明文的补位字符 - *

- * @param decrypted 解密后的明文 - * @return 删除补位字符后的明文 - */ - private static byte[] decodePKCS7(byte[] decrypted) { - int pad = (int) decrypted[decrypted.length - 1]; - if (pad < 1 || pad > 32) pad = 0; - return Arrays.copyOfRange(decrypted, 0, decrypted.length - pad); - } -} diff --git a/src-plugin/readme.txt b/src-plugin/readme.txt deleted file mode 100644 index 8da8c3e69..000000000 --- a/src-plugin/readme.txt +++ /dev/null @@ -1 +0,0 @@ -RedKale的扩展包。 包含常用的QQ登陆、微信企业号、服务号部分接口,IOS的APNS接口 \ No newline at end of file