mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix comment
This commit is contained in:
parent
fb2596b6c7
commit
ea3e59a331
@ -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<String, ?>) bean, unwrapedKeys);
|
||||
return MapUtil.getAny((Map<String, ?>) bean, unWrappedKeys);
|
||||
} else {
|
||||
final Map<String, Object> map = BeanUtil.beanToMap(bean);
|
||||
return MapUtil.getAny(map, unwrapedKeys);
|
||||
return MapUtil.getAny(map, unWrappedKeys);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -632,6 +632,7 @@ public class DateUtil extends CalendarUtil {
|
||||
*
|
||||
* @param date 被格式化的日期
|
||||
* @param isUppercase 是否采用大写形式
|
||||
* @param withTime 是否包含时间部分
|
||||
* @return 中文日期字符串
|
||||
* @since 5.3.9
|
||||
*/
|
||||
|
@ -21,7 +21,7 @@ import java.io.OutputStream;
|
||||
* e.addFrame(image2);
|
||||
* e.finish();
|
||||
* </pre>
|
||||
*
|
||||
* <p>
|
||||
* 来自:https://github.com/rtyley/animated-gif-lib-for-java
|
||||
*
|
||||
* @author Kevin Weiner, FM Software
|
||||
@ -120,6 +120,7 @@ public class AnimatedGifEncoder {
|
||||
* May be set to null to indicate no transparent color.
|
||||
*
|
||||
* @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++) {
|
||||
|
@ -19,7 +19,7 @@ import java.util.ArrayList;
|
||||
/**
|
||||
* GIF文件解析
|
||||
* Class GifDecoder - Decodes a GIF file into one or more frames.
|
||||
*
|
||||
* <p>
|
||||
* Example:
|
||||
*
|
||||
* <pre>
|
||||
@ -34,7 +34,7 @@ import java.util.ArrayList;
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p>
|
||||
* 来自: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() {
|
||||
@ -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;
|
||||
@ -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.
|
||||
@ -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;
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
|
@ -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<String, Object> resultMap = MapUtil.newHashMap();
|
||||
BeanUtil.setProperty(resultMap, "codeList[0].name", "张三");
|
||||
Console.log(resultMap);
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user