diff --git a/hutool-core/src/main/java/cn/hutool/core/bean/BeanPath.java b/hutool-core/src/main/java/cn/hutool/core/bean/BeanPath.java index 47928ddcf..96c95594d 100644 --- a/hutool-core/src/main/java/cn/hutool/core/bean/BeanPath.java +++ b/hutool-core/src/main/java/cn/hutool/core/bean/BeanPath.java @@ -193,16 +193,16 @@ public class BeanPath implements Serializable{ } else if (ArrayUtil.isArray(bean)) { return ArrayUtil.getAny(bean, Convert.convert(int[].class, keys)); } else { - final String[] unwrapedKeys = new String[keys.size()]; - for (int i = 0; i < unwrapedKeys.length; i++) { - unwrapedKeys[i] = StrUtil.unWrap(keys.get(i), '\''); + final String[] unWrappedKeys = new String[keys.size()]; + for (int i = 0; i < unWrappedKeys.length; i++) { + unWrappedKeys[i] = StrUtil.unWrap(keys.get(i), '\''); } if (bean instanceof Map) { // 只支持String为key的Map - return MapUtil.getAny((Map) bean, unwrapedKeys); + return MapUtil.getAny((Map) bean, unWrappedKeys); } else { final Map map = BeanUtil.beanToMap(bean); - return MapUtil.getAny(map, unwrapedKeys); + return MapUtil.getAny(map, unWrappedKeys); } } } else { diff --git a/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java b/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java index e9cf32749..c1575382a 100644 --- a/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java @@ -632,6 +632,7 @@ public class DateUtil extends CalendarUtil { * * @param date 被格式化的日期 * @param isUppercase 是否采用大写形式 + * @param withTime 是否包含时间部分 * @return 中文日期字符串 * @since 5.3.9 */ diff --git a/hutool-core/src/main/java/cn/hutool/core/img/gif/AnimatedGifEncoder.java b/hutool-core/src/main/java/cn/hutool/core/img/gif/AnimatedGifEncoder.java index 8171d8cb0..43bf0df84 100644 --- a/hutool-core/src/main/java/cn/hutool/core/img/gif/AnimatedGifEncoder.java +++ b/hutool-core/src/main/java/cn/hutool/core/img/gif/AnimatedGifEncoder.java @@ -21,7 +21,7 @@ import java.io.OutputStream; * e.addFrame(image2); * e.finish(); * - * + *

* 来自:https://github.com/rtyley/animated-gif-lib-for-java * * @author Kevin Weiner, FM Software @@ -119,7 +119,8 @@ public class AnimatedGifEncoder { * closest one. * May be set to null to indicate no transparent color. * - * @param c Color to be treated as transparent on display. + * @param c Color to be treated as transparent on display. + * @param exactMatch If exactMatch is set to true, transparent color index is search with exact match */ public void setTransparent(Color c, boolean exactMatch) { transparent = c; @@ -192,6 +193,8 @@ public class AnimatedGifEncoder { * Flushes any pending data and closes output file. * If writing to an OutputStream, the stream is not * closed. + * + * @return is ok */ public boolean finish() { if (!started) return false; @@ -344,6 +347,9 @@ public class AnimatedGifEncoder { /** * Returns index of palette color closest to c + * + * @param c Color + * @return index */ protected int findClosest(Color c) { if (colorTab == null) return -1; @@ -368,9 +374,13 @@ public class AnimatedGifEncoder { return minpos; } - /* - * Returns true if the exact matching color is existing, and used in the color palette, otherwise, return false. This method has to be called before - * finishing the image, because after finished the palette is destroyed and it will always return false. + /** + * Returns true if the exact matching color is existing, and used in the color palette, otherwise, return false. + * This method has to be called before finishing the image, + * because after finished the palette is destroyed and it will always return false. + * + * @param c 颜色 + * @return 颜色是否存在 */ boolean isColorUsed(Color c) { return findExact(c) != -1; @@ -378,6 +388,9 @@ public class AnimatedGifEncoder { /** * Returns index of palette exactly matching to color c or -1 if there is no exact matching. + * + * @param c Color + * @return index */ protected int findExact(Color c) { if (colorTab == null) { @@ -422,6 +435,8 @@ public class AnimatedGifEncoder { /** * Writes Graphic Control Extension + * + * @throws IOException IO异常 */ protected void writeGraphicCtrlExt() throws IOException { out.write(0x21); // extension introducer @@ -454,6 +469,8 @@ public class AnimatedGifEncoder { /** * Writes Image Descriptor + * + * @throws IOException IO异常 */ protected void writeImageDesc() throws IOException { out.write(0x2c); // image separator @@ -478,6 +495,8 @@ public class AnimatedGifEncoder { /** * Writes Logical Screen Descriptor + * + * @throws IOException IO异常 */ protected void writeLSD() throws IOException { // logical screen size @@ -497,6 +516,8 @@ public class AnimatedGifEncoder { /** * Writes Netscape application extension to define * repeat count. + * + * @throws IOException IO异常 */ protected void writeNetscapeExt() throws IOException { out.write(0x21); // extension introducer @@ -511,6 +532,8 @@ public class AnimatedGifEncoder { /** * Writes color table + * + * @throws IOException IO异常 */ protected void writePalette() throws IOException { out.write(colorTab, 0, colorTab.length); @@ -522,6 +545,8 @@ public class AnimatedGifEncoder { /** * Encodes and writes pixel data + * + * @throws IOException IO异常 */ protected void writePixels() throws IOException { LZWEncoder encoder = new LZWEncoder(width, height, indexedPixels, colorDepth); @@ -530,6 +555,9 @@ public class AnimatedGifEncoder { /** * Write 16-bit value to output stream, LSB first + * + * @param value 16-bit value + * @throws IOException IO异常 */ protected void writeShort(int value) throws IOException { out.write(value & 0xff); @@ -538,6 +566,9 @@ public class AnimatedGifEncoder { /** * Writes string to output stream + * + * @param s String + * @throws IOException IO异常 */ protected void writeString(String s) throws IOException { for (int i = 0; i < s.length(); i++) { diff --git a/hutool-core/src/main/java/cn/hutool/core/img/gif/GifDecoder.java b/hutool-core/src/main/java/cn/hutool/core/img/gif/GifDecoder.java index 376c989b7..97353f787 100644 --- a/hutool-core/src/main/java/cn/hutool/core/img/gif/GifDecoder.java +++ b/hutool-core/src/main/java/cn/hutool/core/img/gif/GifDecoder.java @@ -19,7 +19,7 @@ import java.util.ArrayList; /** * GIF文件解析 * Class GifDecoder - Decodes a GIF file into one or more frames. - * + *

* Example: * *

@@ -34,7 +34,7 @@ import java.util.ArrayList;
  *    }
  * }
  * 
- * + *

* 来自:https://github.com/rtyley/animated-gif-lib-for-java * * @author Kevin Weiner, FM Software; LZW decoder adapted from John Cristy's ImageMagick. @@ -112,6 +112,7 @@ public class GifDecoder { image = im; delay = del; } + public BufferedImage image; public int delay; } @@ -133,6 +134,7 @@ public class GifDecoder { /** * Gets the number of frames read from file. + * * @return frame count */ public int getFrameCount() { @@ -165,7 +167,7 @@ public class GifDecoder { protected void setPixels() { // expose destination image's pixels as int array int[] dest = - ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); + ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); // fill in starting image contents based on last image's dispose code if (lastDispose > 0) { @@ -181,7 +183,7 @@ public class GifDecoder { if (lastImage != null) { int[] prev = - ((DataBufferInt) lastImage.getRaster().getDataBuffer()).getData(); + ((DataBufferInt) lastImage.getRaster().getDataBuffer()).getData(); System.arraycopy(prev, 0, dest, 0, width * height); // copy pixels @@ -190,7 +192,7 @@ public class GifDecoder { Graphics2D g = image.createGraphics(); Color c; if (transparency) { - c = new Color(0, 0, 0, 0); // assume background is transparent + c = new Color(0, 0, 0, 0); // assume background is transparent } else { c = new Color(lastBgColor); // use given background color } @@ -212,14 +214,14 @@ public class GifDecoder { if (iline >= ih) { pass++; switch (pass) { - case 2 : + case 2: iline = 4; break; - case 3 : + case 3: iline = 2; inc = 4; break; - case 4 : + case 4: iline = 1; inc = 2; } @@ -252,7 +254,8 @@ public class GifDecoder { /** * Gets the image contents of frame n. * - * @return BufferedImage representation of frame, or null if n is invalid. + * @param n frame + * @return BufferedImage */ public BufferedImage getFrame(int n) { BufferedImage im = null; @@ -322,7 +325,7 @@ public class GifDecoder { } /** - * Reads GIF file from specified file/URL source + * Reads GIF file from specified file/URL source * (URL assumed if name contains ":/" or "file:") * * @param name String containing source @@ -333,7 +336,7 @@ public class GifDecoder { try { name = name.trim().toLowerCase(); if ((name.contains("file:")) || - (name.indexOf(":/") > 0)) { + (name.indexOf(":/") > 0)) { URL url = new URL(name); in = new BufferedInputStream(url.openStream()); } else { @@ -354,23 +357,23 @@ public class GifDecoder { protected void decodeImageData() { int NullCode = -1; int npix = iw * ih; - int available, - clear, - code_mask, - code_size, - end_of_information, - in_code, - old_code, - bits, - code, - count, - i, - datum, - data_size, - first, - top, - bi, - pi; + int available, + clear, + code_mask, + code_size, + end_of_information, + in_code, + old_code, + bits, + code, + count, + i, + datum, + data_size, + first, + top, + bi, + pi; if ((pixels == null) || (pixels.length < npix)) { pixels = new byte[npix]; // allocate new pixel array @@ -397,7 +400,7 @@ public class GifDecoder { datum = bits = count = first = top = pi = bi = 0; - for (i = 0; i < npix;) { + for (i = 0; i < npix; ) { if (top == 0) { if (bits < code_size) { // Load bytes until there are enough bits for a code. @@ -461,7 +464,7 @@ public class GifDecoder { suffix[available] = (byte) first; available++; if (((available & code_mask) == 0) - && (available < MaxStackSize)) { + && (available < MaxStackSize)) { code_size++; code_mask += available; } @@ -483,6 +486,8 @@ public class GifDecoder { /** * Returns true if an error was encountered during reading/decoding + * + * @return true if an error was encountered during reading/decoding */ protected boolean err() { return status != STATUS_OK; @@ -501,6 +506,8 @@ public class GifDecoder { /** * Reads a single byte from the input stream. + * + * @return single byte */ protected int read() { int curByte = 0; @@ -525,7 +532,7 @@ public class GifDecoder { int count; while (n < blockSize) { count = in.read(block, n, blockSize - n); - if (count == -1) + if (count == -1) break; n += count; } @@ -582,18 +589,18 @@ public class GifDecoder { int code = read(); switch (code) { - case 0x2C : // image separator + case 0x2C: // image separator readImage(); break; - case 0x21 : // extension + case 0x21: // extension code = read(); switch (code) { - case 0xf9 : // graphics control extension + case 0xf9: // graphics control extension readGraphicControlExt(); break; - case 0xff : // application extension + case 0xff: // application extension readBlock(); final StringBuilder app = new StringBuilder(); for (int i = 0; i < 11; i++) { @@ -601,24 +608,23 @@ public class GifDecoder { } if (app.toString().equals("NETSCAPE2.0")) { readNetscapeExt(); - } - else + } else skip(); // don't care break; - default : // uninteresting extension + default: // uninteresting extension skip(); } break; - case 0x3b : // terminator + case 0x3b: // terminator done = true; break; - case 0x00 : // bad byte, but keep going and see what happens + case 0x00: // bad byte, but keep going and see what happens break; - default : + default: status = STATUS_FORMAT_ERROR; } } @@ -705,7 +711,7 @@ public class GifDecoder { // create new image to receive frame data image = - new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB_PRE); + new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB_PRE); setPixels(); // transfer pixel data to image @@ -755,6 +761,8 @@ public class GifDecoder { /** * Reads next 16-bit value, LSB first + * + * @return next 16-bit value */ protected int readShort() { // read 16-bit value, LSB first diff --git a/hutool-core/src/test/java/cn/hutool/core/bean/BeanUtilTest.java b/hutool-core/src/test/java/cn/hutool/core/bean/BeanUtilTest.java index 0f7912b08..d0a8909d4 100644 --- a/hutool-core/src/test/java/cn/hutool/core/bean/BeanUtilTest.java +++ b/hutool-core/src/test/java/cn/hutool/core/bean/BeanUtilTest.java @@ -4,6 +4,7 @@ import cn.hutool.core.annotation.Alias; import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.ValueProvider; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Console; import cn.hutool.core.map.MapUtil; import lombok.Data; import lombok.Getter; @@ -404,4 +405,11 @@ public class BeanUtilTest { @Alias("code") private String code2; } + + @Test + public void setPropertiesTest(){ + Map resultMap = MapUtil.newHashMap(); + BeanUtil.setProperty(resultMap, "codeList[0].name", "张三"); + Console.log(resultMap); + } } diff --git a/hutool-core/src/test/java/cn/hutool/core/date/LocalDateTimeUtilTest.java b/hutool-core/src/test/java/cn/hutool/core/date/LocalDateTimeUtilTest.java index 9fdcc59f9..24d8ada86 100644 --- a/hutool-core/src/test/java/cn/hutool/core/date/LocalDateTimeUtilTest.java +++ b/hutool-core/src/test/java/cn/hutool/core/date/LocalDateTimeUtilTest.java @@ -52,6 +52,12 @@ public class LocalDateTimeUtilTest { Assert.assertEquals("2020-01-23T12:23:56", localDateTime.toString()); } + @Test + public void parseTest5() { + final LocalDateTime localDateTime = LocalDateTimeUtil.parse("2020-01-23T12:23:56"); + Assert.assertEquals("2020-01-23T12:23:56", localDateTime.toString()); + } + @Test public void formatTest() { final LocalDateTime localDateTime = LocalDateTimeUtil.parse("2020-01-23T12:23:56");