mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix issue#503
This commit is contained in:
@@ -7,18 +7,20 @@ import java.util.Date;
|
|||||||
/**
|
/**
|
||||||
* 基本类型的getter接口<br>
|
* 基本类型的getter接口<br>
|
||||||
* 提供一个统一的接口定义返回不同类型的值(基本类型)<br>
|
* 提供一个统一的接口定义返回不同类型的值(基本类型)<br>
|
||||||
|
*
|
||||||
* @author Looly
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
public interface BasicTypeGetter<K> {
|
public interface BasicTypeGetter<K> {
|
||||||
/*-------------------------- 基本类型 start -------------------------------*/
|
/*-------------------------- 基本类型 start -------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取Object属性值
|
* 获取Object属性值
|
||||||
|
*
|
||||||
* @param key 属性名
|
* @param key 属性名
|
||||||
* @return 属性值
|
* @return 属性值
|
||||||
*/
|
*/
|
||||||
Object getObj(K key);
|
Object getObj(K key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取字符串型属性值
|
* 获取字符串型属性值
|
||||||
*
|
*
|
||||||
@@ -26,7 +28,7 @@ public interface BasicTypeGetter<K> {
|
|||||||
* @return 属性值
|
* @return 属性值
|
||||||
*/
|
*/
|
||||||
String getStr(K key);
|
String getStr(K key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取int型属性值
|
* 获取int型属性值
|
||||||
*
|
*
|
||||||
@@ -34,7 +36,7 @@ public interface BasicTypeGetter<K> {
|
|||||||
* @return 属性值
|
* @return 属性值
|
||||||
*/
|
*/
|
||||||
Integer getInt(K key);
|
Integer getInt(K key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取short型属性值
|
* 获取short型属性值
|
||||||
*
|
*
|
||||||
@@ -42,7 +44,7 @@ public interface BasicTypeGetter<K> {
|
|||||||
* @return 属性值
|
* @return 属性值
|
||||||
*/
|
*/
|
||||||
Short getShort(K key);
|
Short getShort(K key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取boolean型属性值
|
* 获取boolean型属性值
|
||||||
*
|
*
|
||||||
@@ -50,7 +52,7 @@ public interface BasicTypeGetter<K> {
|
|||||||
* @return 属性值
|
* @return 属性值
|
||||||
*/
|
*/
|
||||||
Boolean getBool(K key);
|
Boolean getBool(K key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取long型属性值
|
* 获取long型属性值
|
||||||
*
|
*
|
||||||
@@ -58,7 +60,7 @@ public interface BasicTypeGetter<K> {
|
|||||||
* @return 属性值
|
* @return 属性值
|
||||||
*/
|
*/
|
||||||
Long getLong(K key);
|
Long getLong(K key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取char型属性值
|
* 获取char型属性值
|
||||||
*
|
*
|
||||||
@@ -66,7 +68,7 @@ public interface BasicTypeGetter<K> {
|
|||||||
* @return 属性值
|
* @return 属性值
|
||||||
*/
|
*/
|
||||||
Character getChar(K key);
|
Character getChar(K key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取float型属性值<br>
|
* 获取float型属性值<br>
|
||||||
*
|
*
|
||||||
@@ -74,7 +76,7 @@ public interface BasicTypeGetter<K> {
|
|||||||
* @return 属性值
|
* @return 属性值
|
||||||
*/
|
*/
|
||||||
Float getFloat(K key);
|
Float getFloat(K key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取double型属性值
|
* 获取double型属性值
|
||||||
*
|
*
|
||||||
@@ -82,7 +84,7 @@ public interface BasicTypeGetter<K> {
|
|||||||
* @return 属性值
|
* @return 属性值
|
||||||
*/
|
*/
|
||||||
Double getDouble(K key);
|
Double getDouble(K key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取byte型属性值
|
* 获取byte型属性值
|
||||||
*
|
*
|
||||||
@@ -90,7 +92,7 @@ public interface BasicTypeGetter<K> {
|
|||||||
* @return 属性值
|
* @return 属性值
|
||||||
*/
|
*/
|
||||||
Byte getByte(K key);
|
Byte getByte(K key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取BigDecimal型属性值
|
* 获取BigDecimal型属性值
|
||||||
*
|
*
|
||||||
@@ -98,7 +100,7 @@ public interface BasicTypeGetter<K> {
|
|||||||
* @return 属性值
|
* @return 属性值
|
||||||
*/
|
*/
|
||||||
BigDecimal getBigDecimal(K key);
|
BigDecimal getBigDecimal(K key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取BigInteger型属性值
|
* 获取BigInteger型属性值
|
||||||
*
|
*
|
||||||
@@ -106,7 +108,7 @@ public interface BasicTypeGetter<K> {
|
|||||||
* @return 属性值
|
* @return 属性值
|
||||||
*/
|
*/
|
||||||
BigInteger getBigInteger(K key);
|
BigInteger getBigInteger(K key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得Enum类型的值
|
* 获得Enum类型的值
|
||||||
*
|
*
|
||||||
@@ -116,9 +118,10 @@ public interface BasicTypeGetter<K> {
|
|||||||
* @return Enum类型的值,无则返回Null
|
* @return Enum类型的值,无则返回Null
|
||||||
*/
|
*/
|
||||||
<E extends Enum<E>> E getEnum(Class<E> clazz, K key);
|
<E extends Enum<E>> E getEnum(Class<E> clazz, K key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取Date类型值
|
* 获取Date类型值
|
||||||
|
*
|
||||||
* @param key 属性名
|
* @param key 属性名
|
||||||
* @return Date类型属性值
|
* @return Date类型属性值
|
||||||
*/
|
*/
|
||||||
|
@@ -26,7 +26,7 @@ public class Dict extends LinkedHashMap<String, Object> implements BasicTypeGett
|
|||||||
|
|
||||||
static final float DEFAULT_LOAD_FACTOR = 0.75f;
|
static final float DEFAULT_LOAD_FACTOR = 0.75f;
|
||||||
static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; // aka 16
|
static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; // aka 16
|
||||||
|
|
||||||
/** 是否大小写不敏感 */
|
/** 是否大小写不敏感 */
|
||||||
private boolean caseInsensitive;
|
private boolean caseInsensitive;
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ public class Dict extends LinkedHashMap<String, Object> implements BasicTypeGett
|
|||||||
public Dict() {
|
public Dict() {
|
||||||
this(false);
|
this(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造
|
* 构造
|
||||||
*
|
*
|
||||||
@@ -77,7 +77,7 @@ public class Dict extends LinkedHashMap<String, Object> implements BasicTypeGett
|
|||||||
public Dict(int initialCapacity) {
|
public Dict(int initialCapacity) {
|
||||||
this(initialCapacity, false);
|
this(initialCapacity, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造
|
* 构造
|
||||||
*
|
*
|
||||||
@@ -87,7 +87,7 @@ public class Dict extends LinkedHashMap<String, Object> implements BasicTypeGett
|
|||||||
public Dict(int initialCapacity, boolean caseInsensitive) {
|
public Dict(int initialCapacity, boolean caseInsensitive) {
|
||||||
this(initialCapacity, DEFAULT_LOAD_FACTOR, caseInsensitive);
|
this(initialCapacity, DEFAULT_LOAD_FACTOR, caseInsensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造
|
* 构造
|
||||||
*
|
*
|
||||||
@@ -297,6 +297,19 @@ public class Dict extends LinkedHashMap<String, Object> implements BasicTypeGett
|
|||||||
return super.get(key);
|
return super.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得特定类型值
|
||||||
|
*
|
||||||
|
* @param <T> 值类型
|
||||||
|
* @param attr 字段名
|
||||||
|
* @param defaultValue 默认值
|
||||||
|
* @return 字段值
|
||||||
|
* @since 4.6.3
|
||||||
|
*/
|
||||||
|
public <T> T getBean(String attr) {
|
||||||
|
return get(attr, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得特定类型值
|
* 获得特定类型值
|
||||||
*
|
*
|
||||||
@@ -439,7 +452,7 @@ public class Dict extends LinkedHashMap<String, Object> implements BasicTypeGett
|
|||||||
return get(attr, null);
|
return get(attr, null);
|
||||||
}
|
}
|
||||||
// -------------------------------------------------------------------- Get end
|
// -------------------------------------------------------------------- Get end
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object put(String key, Object value) {
|
public Object put(String key, Object value) {
|
||||||
return super.put(customKey(key), value);
|
return super.put(customKey(key), value);
|
||||||
@@ -449,7 +462,7 @@ public class Dict extends LinkedHashMap<String, Object> implements BasicTypeGett
|
|||||||
public Dict clone() {
|
public Dict clone() {
|
||||||
return (Dict) super.clone();
|
return (Dict) super.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将Key转为小写
|
* 将Key转为小写
|
||||||
*
|
*
|
||||||
|
@@ -3,6 +3,7 @@ package cn.hutool.core.swing;
|
|||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
import cn.hutool.core.util.URLUtil;
|
import cn.hutool.core.util.URLUtil;
|
||||||
@@ -31,9 +32,19 @@ public class DesktopUtil {
|
|||||||
* @param url URL地址
|
* @param url URL地址
|
||||||
*/
|
*/
|
||||||
public static void browse(String url) {
|
public static void browse(String url) {
|
||||||
|
browse(URLUtil.toURI(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用平台默认浏览器打开指定URI地址
|
||||||
|
*
|
||||||
|
* @param uri URI地址
|
||||||
|
* @since 4.6.3
|
||||||
|
*/
|
||||||
|
public static void browse(URI uri) {
|
||||||
final Desktop dsktop = getDsktop();
|
final Desktop dsktop = getDsktop();
|
||||||
try {
|
try {
|
||||||
dsktop.browse(URLUtil.toURI(url));
|
dsktop.browse(uri);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IORuntimeException(e);
|
throw new IORuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@@ -285,7 +285,7 @@ public class JschUtil {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IORuntimeException(e);
|
throw new IORuntimeException(e);
|
||||||
} catch (JSchException e) {
|
} catch (JSchException e) {
|
||||||
throw new IORuntimeException(e);
|
throw new JschRuntimeException(e);
|
||||||
} finally {
|
} finally {
|
||||||
IoUtil.close(in);
|
IoUtil.close(in);
|
||||||
close(channel);
|
close(channel);
|
||||||
|
Reference in New Issue
Block a user