fix comment

This commit is contained in:
Looly 2020-07-13 09:20:17 +08:00
parent fb2596b6c7
commit ea3e59a331
6 changed files with 106 additions and 52 deletions

View File

@ -193,16 +193,16 @@ public class BeanPath implements Serializable{
} else if (ArrayUtil.isArray(bean)) { } else if (ArrayUtil.isArray(bean)) {
return ArrayUtil.getAny(bean, Convert.convert(int[].class, keys)); return ArrayUtil.getAny(bean, Convert.convert(int[].class, keys));
} else { } else {
final String[] unwrapedKeys = new String[keys.size()]; final String[] unWrappedKeys = new String[keys.size()];
for (int i = 0; i < unwrapedKeys.length; i++) { for (int i = 0; i < unWrappedKeys.length; i++) {
unwrapedKeys[i] = StrUtil.unWrap(keys.get(i), '\''); unWrappedKeys[i] = StrUtil.unWrap(keys.get(i), '\'');
} }
if (bean instanceof Map) { if (bean instanceof Map) {
// 只支持String为key的Map // 只支持String为key的Map
return MapUtil.getAny((Map<String, ?>) bean, unwrapedKeys); return MapUtil.getAny((Map<String, ?>) bean, unWrappedKeys);
} else { } else {
final Map<String, Object> map = BeanUtil.beanToMap(bean); final Map<String, Object> map = BeanUtil.beanToMap(bean);
return MapUtil.getAny(map, unwrapedKeys); return MapUtil.getAny(map, unWrappedKeys);
} }
} }
} else { } else {

View File

@ -632,6 +632,7 @@ public class DateUtil extends CalendarUtil {
* *
* @param date 被格式化的日期 * @param date 被格式化的日期
* @param isUppercase 是否采用大写形式 * @param isUppercase 是否采用大写形式
* @param withTime 是否包含时间部分
* @return 中文日期字符串 * @return 中文日期字符串
* @since 5.3.9 * @since 5.3.9
*/ */

View File

@ -21,7 +21,7 @@ import java.io.OutputStream;
* e.addFrame(image2); * e.addFrame(image2);
* e.finish(); * e.finish();
* </pre> * </pre>
* * <p>
* 来自https://github.com/rtyley/animated-gif-lib-for-java * 来自https://github.com/rtyley/animated-gif-lib-for-java
* *
* @author Kevin Weiner, FM Software * @author Kevin Weiner, FM Software
@ -120,6 +120,7 @@ public class AnimatedGifEncoder {
* May be set to null to indicate no transparent color. * 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) { public void setTransparent(Color c, boolean exactMatch) {
transparent = c; transparent = c;
@ -192,6 +193,8 @@ public class AnimatedGifEncoder {
* Flushes any pending data and closes output file. * Flushes any pending data and closes output file.
* If writing to an OutputStream, the stream is not * If writing to an OutputStream, the stream is not
* closed. * closed.
*
* @return is ok
*/ */
public boolean finish() { public boolean finish() {
if (!started) return false; if (!started) return false;
@ -344,6 +347,9 @@ public class AnimatedGifEncoder {
/** /**
* Returns index of palette color closest to c * Returns index of palette color closest to c
*
* @param c Color
* @return index
*/ */
protected int findClosest(Color c) { protected int findClosest(Color c) {
if (colorTab == null) return -1; if (colorTab == null) return -1;
@ -368,9 +374,13 @@ public class AnimatedGifEncoder {
return minpos; 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 * Returns true if the exact matching color is existing, and used in the color palette, otherwise, return false.
* finishing the image, because after finished the palette is destroyed and it will always 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) { boolean isColorUsed(Color c) {
return findExact(c) != -1; 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. * 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) { protected int findExact(Color c) {
if (colorTab == null) { if (colorTab == null) {
@ -422,6 +435,8 @@ public class AnimatedGifEncoder {
/** /**
* Writes Graphic Control Extension * Writes Graphic Control Extension
*
* @throws IOException IO异常
*/ */
protected void writeGraphicCtrlExt() throws IOException { protected void writeGraphicCtrlExt() throws IOException {
out.write(0x21); // extension introducer out.write(0x21); // extension introducer
@ -454,6 +469,8 @@ public class AnimatedGifEncoder {
/** /**
* Writes Image Descriptor * Writes Image Descriptor
*
* @throws IOException IO异常
*/ */
protected void writeImageDesc() throws IOException { protected void writeImageDesc() throws IOException {
out.write(0x2c); // image separator out.write(0x2c); // image separator
@ -478,6 +495,8 @@ public class AnimatedGifEncoder {
/** /**
* Writes Logical Screen Descriptor * Writes Logical Screen Descriptor
*
* @throws IOException IO异常
*/ */
protected void writeLSD() throws IOException { protected void writeLSD() throws IOException {
// logical screen size // logical screen size
@ -497,6 +516,8 @@ public class AnimatedGifEncoder {
/** /**
* Writes Netscape application extension to define * Writes Netscape application extension to define
* repeat count. * repeat count.
*
* @throws IOException IO异常
*/ */
protected void writeNetscapeExt() throws IOException { protected void writeNetscapeExt() throws IOException {
out.write(0x21); // extension introducer out.write(0x21); // extension introducer
@ -511,6 +532,8 @@ public class AnimatedGifEncoder {
/** /**
* Writes color table * Writes color table
*
* @throws IOException IO异常
*/ */
protected void writePalette() throws IOException { protected void writePalette() throws IOException {
out.write(colorTab, 0, colorTab.length); out.write(colorTab, 0, colorTab.length);
@ -522,6 +545,8 @@ public class AnimatedGifEncoder {
/** /**
* Encodes and writes pixel data * Encodes and writes pixel data
*
* @throws IOException IO异常
*/ */
protected void writePixels() throws IOException { protected void writePixels() throws IOException {
LZWEncoder encoder = new LZWEncoder(width, height, indexedPixels, colorDepth); LZWEncoder encoder = new LZWEncoder(width, height, indexedPixels, colorDepth);
@ -530,6 +555,9 @@ public class AnimatedGifEncoder {
/** /**
* Write 16-bit value to output stream, LSB first * Write 16-bit value to output stream, LSB first
*
* @param value 16-bit value
* @throws IOException IO异常
*/ */
protected void writeShort(int value) throws IOException { protected void writeShort(int value) throws IOException {
out.write(value & 0xff); out.write(value & 0xff);
@ -538,6 +566,9 @@ public class AnimatedGifEncoder {
/** /**
* Writes string to output stream * Writes string to output stream
*
* @param s String
* @throws IOException IO异常
*/ */
protected void writeString(String s) throws IOException { protected void writeString(String s) throws IOException {
for (int i = 0; i < s.length(); i++) { for (int i = 0; i < s.length(); i++) {

View File

@ -19,7 +19,7 @@ import java.util.ArrayList;
/** /**
* GIF文件解析 * GIF文件解析
* Class GifDecoder - Decodes a GIF file into one or more frames. * Class GifDecoder - Decodes a GIF file into one or more frames.
* * <p>
* Example: * Example:
* *
* <pre> * <pre>
@ -34,7 +34,7 @@ import java.util.ArrayList;
* } * }
* } * }
* </pre> * </pre>
* * <p>
* 来自https://github.com/rtyley/animated-gif-lib-for-java * 来自https://github.com/rtyley/animated-gif-lib-for-java
* *
* @author Kevin Weiner, FM Software; LZW decoder adapted from John Cristy's ImageMagick. * @author Kevin Weiner, FM Software; LZW decoder adapted from John Cristy's ImageMagick.
@ -112,6 +112,7 @@ public class GifDecoder {
image = im; image = im;
delay = del; delay = del;
} }
public BufferedImage image; public BufferedImage image;
public int delay; public int delay;
} }
@ -133,6 +134,7 @@ public class GifDecoder {
/** /**
* Gets the number of frames read from file. * Gets the number of frames read from file.
*
* @return frame count * @return frame count
*/ */
public int getFrameCount() { public int getFrameCount() {
@ -252,7 +254,8 @@ public class GifDecoder {
/** /**
* Gets the image contents of frame n. * 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) { public BufferedImage getFrame(int n) {
BufferedImage im = null; BufferedImage im = null;
@ -483,6 +486,8 @@ public class GifDecoder {
/** /**
* Returns true if an error was encountered during reading/decoding * Returns true if an error was encountered during reading/decoding
*
* @return true if an error was encountered during reading/decoding
*/ */
protected boolean err() { protected boolean err() {
return status != STATUS_OK; return status != STATUS_OK;
@ -501,6 +506,8 @@ public class GifDecoder {
/** /**
* Reads a single byte from the input stream. * Reads a single byte from the input stream.
*
* @return single byte
*/ */
protected int read() { protected int read() {
int curByte = 0; int curByte = 0;
@ -601,8 +608,7 @@ public class GifDecoder {
} }
if (app.toString().equals("NETSCAPE2.0")) { if (app.toString().equals("NETSCAPE2.0")) {
readNetscapeExt(); readNetscapeExt();
} } else
else
skip(); // don't care skip(); // don't care
break; break;
@ -755,6 +761,8 @@ public class GifDecoder {
/** /**
* Reads next 16-bit value, LSB first * Reads next 16-bit value, LSB first
*
* @return next 16-bit value
*/ */
protected int readShort() { protected int readShort() {
// read 16-bit value, LSB first // read 16-bit value, LSB first

View File

@ -4,6 +4,7 @@ import cn.hutool.core.annotation.Alias;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.bean.copier.ValueProvider; import cn.hutool.core.bean.copier.ValueProvider;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Console;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import lombok.Data; import lombok.Data;
import lombok.Getter; import lombok.Getter;
@ -404,4 +405,11 @@ public class BeanUtilTest {
@Alias("code") @Alias("code")
private String code2; private String code2;
} }
@Test
public void setPropertiesTest(){
Map<String, Object> resultMap = MapUtil.newHashMap();
BeanUtil.setProperty(resultMap, "codeList[0].name", "张三");
Console.log(resultMap);
}
} }

View File

@ -52,6 +52,12 @@ public class LocalDateTimeUtilTest {
Assert.assertEquals("2020-01-23T12:23:56", localDateTime.toString()); 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 @Test
public void formatTest() { public void formatTest() {
final LocalDateTime localDateTime = LocalDateTimeUtil.parse("2020-01-23T12:23:56"); final LocalDateTime localDateTime = LocalDateTimeUtil.parse("2020-01-23T12:23:56");