mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
174e6cb53d
commit
07660517b9
@ -6,7 +6,9 @@
|
|||||||
## 5.0.4
|
## 5.0.4
|
||||||
|
|
||||||
### 新特性
|
### 新特性
|
||||||
|
* 【core】 XmlUtil中mapToStr支持namespace(pr#599@Github)
|
||||||
### Bug修复
|
### Bug修复
|
||||||
|
* 【core】 解决ConcurrentHashSet不能序列化的问题(issue#600@Github)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ public class ConcurrentHashSet<E> extends AbstractSet<E> implements java.io.Seri
|
|||||||
private static final long serialVersionUID = 7997886765361607470L;
|
private static final long serialVersionUID = 7997886765361607470L;
|
||||||
|
|
||||||
/** 持有对象。如果值为此对象表示有数据,否则无数据 */
|
/** 持有对象。如果值为此对象表示有数据,否则无数据 */
|
||||||
private static final Object PRESENT = new Object();
|
private static final Boolean PRESENT = true;
|
||||||
private final ConcurrentHashMap<E, Object> map;
|
private final ConcurrentHashMap<E, Boolean> map;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------- Constructor start
|
// ----------------------------------------------------------------------------------- Constructor start
|
||||||
/**
|
/**
|
||||||
|
@ -387,8 +387,7 @@ public class XmlUtil {
|
|||||||
* @since 4.1.2
|
* @since 4.1.2
|
||||||
*/
|
*/
|
||||||
public static DocumentBuilder createDocumentBuilder() {
|
public static DocumentBuilder createDocumentBuilder() {
|
||||||
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
final DocumentBuilderFactory dbf = disableXXE(DocumentBuilderFactory.newInstance());
|
||||||
disableXXE(dbf);
|
|
||||||
DocumentBuilder builder;
|
DocumentBuilder builder;
|
||||||
try {
|
try {
|
||||||
builder = dbf.newDocumentBuilder();
|
builder = dbf.newDocumentBuilder();
|
||||||
@ -406,9 +405,21 @@ public class XmlUtil {
|
|||||||
* @return XML文档
|
* @return XML文档
|
||||||
*/
|
*/
|
||||||
public static Document createXml(String rootElementName) {
|
public static Document createXml(String rootElementName) {
|
||||||
final Document doc = createXml();
|
return createXml(rootElementName, null);
|
||||||
doc.appendChild(doc.createElement(rootElementName));
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建XML文档<br>
|
||||||
|
* 创建的XML默认是utf8编码,修改编码的过程是在toStr和toFile方法里,即XML在转为文本的时候才定义编码
|
||||||
|
*
|
||||||
|
* @param rootElementName 根节点名称
|
||||||
|
* @param namespace 命名空间,无则传null
|
||||||
|
* @return XML文档
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public static Document createXml(String rootElementName, String namespace) {
|
||||||
|
final Document doc = createXml();
|
||||||
|
doc.appendChild(null == namespace ? doc.createElement(rootElementName) : doc.createElementNS(rootElementName, namespace));
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -674,7 +685,7 @@ public class XmlUtil {
|
|||||||
* @since 4.0.8
|
* @since 4.0.8
|
||||||
*/
|
*/
|
||||||
public static Map<String, Object> xmlToMap(String xmlStr) {
|
public static Map<String, Object> xmlToMap(String xmlStr) {
|
||||||
return xmlToMap(xmlStr, new HashMap<String, Object>());
|
return xmlToMap(xmlStr, new HashMap<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -685,7 +696,7 @@ public class XmlUtil {
|
|||||||
* @since 4.0.8
|
* @since 4.0.8
|
||||||
*/
|
*/
|
||||||
public static Map<String, Object> xmlToMap(Node node) {
|
public static Map<String, Object> xmlToMap(Node node) {
|
||||||
return xmlToMap(node, new HashMap<String, Object>());
|
return xmlToMap(node, new HashMap<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -804,9 +815,22 @@ public class XmlUtil {
|
|||||||
* @return 子节点
|
* @return 子节点
|
||||||
* @since 4.0.9
|
* @since 4.0.9
|
||||||
*/
|
*/
|
||||||
|
public static Element appendChild(Node node, String tagName) {
|
||||||
|
return appendChild(node, tagName, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在已有节点上创建子节点
|
||||||
|
*
|
||||||
|
* @param node 节点
|
||||||
|
* @param tagName 标签名
|
||||||
|
* @param namespace 命名空间,无传null
|
||||||
|
* @return 子节点
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
public static Element appendChild(Node node, String tagName, String namespace) {
|
public static Element appendChild(Node node, String tagName, String namespace) {
|
||||||
Document doc = (node instanceof Document) ? (Document) node : node.getOwnerDocument();
|
Document doc = (node instanceof Document) ? (Document) node : node.getOwnerDocument();
|
||||||
Element child = doc.createElementNS(namespace, tagName);
|
Element child = (null == namespace) ? doc.createElement(tagName) : doc.createElementNS(namespace, tagName);
|
||||||
node.appendChild(child);
|
node.appendChild(child);
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class Page implements Serializable {
|
|||||||
* @param pageSize 每页结果数
|
* @param pageSize 每页结果数
|
||||||
*/
|
*/
|
||||||
public Page(int pageNumber, int pageSize) {
|
public Page(int pageNumber, int pageSize) {
|
||||||
this.pageNumber = pageNumber < 0 ? 0 : pageNumber;
|
this.pageNumber = Math.max(pageNumber, 0);
|
||||||
this.pageSize = pageSize <= 0 ? DEFAULT_PAGE_SIZE : pageSize;
|
this.pageSize = pageSize <= 0 ? DEFAULT_PAGE_SIZE : pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ public class Page implements Serializable {
|
|||||||
* @param pageNumber 页码
|
* @param pageNumber 页码
|
||||||
*/
|
*/
|
||||||
public void setPageNumber(int pageNumber) {
|
public void setPageNumber(int pageNumber) {
|
||||||
this.pageNumber = pageNumber < 0 ? 0 : pageNumber;
|
this.pageNumber = Math.max(pageNumber, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user