本文整理了Java中jodd.util.Util
类的一些代码示例,展示了Util
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util
类的具体详情如下:
包路径:jodd.util.Util
类名称:Util
[英]Some general utilities. All methods are safe as possible and operates with as many types as possible.
[中]一些通用工具。所有方法都是尽可能安全的,并且使用尽可能多的类型。
代码示例来源:origin: oblac/jodd
public XmlDeclaration(final Document ownerDocument, final CharSequence version, final CharSequence encoding, final CharSequence standalone) {
super(ownerDocument, NodeType.XML_DECLARATION, "xml");
this.version = Util.toString(version);
this.encoding = Util.toString(encoding);
this.standalone = Util.toString(standalone);
}
代码示例来源:origin: redisson/redisson
/**
* Compares 2 strings. If one of the strings is <code>null</code>, <code>false</code> is returned. if
* both string are <code>null</code>, <code>true</code> is returned.
*
* @param s1 first string to compare
* @param s2 second string
*
* @return <code>true</code> if strings are equal, otherwise <code>false</code>
*/
public static boolean equals(String s1, String s2) {
return Util.equals(s1, s2);
}
代码示例来源:origin: oblac/jodd
@Test
void testLength() {
assertEquals(0, Util.length(null));
assertEquals(-1, Util.length(1234));
assertEquals(0, Util.length(StringPool.EMPTY));
assertEquals(4, Util.length("abcd"));
Collection<String> coll = new ArrayList<>();
assertEquals(0, Util.length(coll));
coll.add("abcd");
coll.add("1234");
assertEquals(2, Util.length(coll));
Iterator<String> iterator = coll.iterator();
assertEquals(2, Util.length(iterator));
Map<Long, String> map = new HashMap<>();
assertEquals(0, Util.length(map));
map.put(1l, "abcd");
map.put(2l, "1234");
assertEquals(2, Util.length(map));
Integer[] array = new Integer[] { 1, 2, 3, 4, 5 };
assertEquals(5, Util.length(array));
ArrayEnumeration<Integer> ae = new ArrayEnumeration<>(array);
assertEquals(5, Util.length(ae));
}
代码示例来源:origin: oblac/jodd
@Test
void testContainsElement() {
assertFalse(Util.containsElement(null, "abcd"));
assertFalse(Util.containsElement(1234, "abcd"));
assertFalse(Util.containsElement("abcd", null));
assertTrue(Util.containsElement("abcd", "bc"));
assertFalse(Util.containsElement("abcd", "xx"));
assertTrue(Util.containsElement(coll, "abcd"));
assertFalse(Util.containsElement(coll, "xx"));
assertTrue(Util.containsElement(iterator, "abcd"));
assertFalse(Util.containsElement(iterator, "xx"));
assertTrue(Util.containsElement(map, "abcd"));
assertFalse(Util.containsElement(map, "xx"));
assertTrue(Util.containsElement(array, 1));
assertFalse(Util.containsElement(array, 10));
ArrayEnumeration<Integer> ae = new ArrayEnumeration<>(array);
assertTrue(Util.containsElement(ae, 1));
assertFalse(Util.containsElement(ae, 10));
代码示例来源:origin: oblac/jodd
@Override
public void doctype(final Doctype doctype) {
if (!enabled) {
return;
}
DocumentType documentType = new DocumentType(rootNode,
Util.toString(doctype.getName()),
Util.toString(doctype.getPublicIdentifier()),
Util.toString(doctype.getSystemIdentifier())
);
parentNode.addChild(documentType);
}
代码示例来源:origin: oblac/jodd
/**
* Compares 2 strings. If one of the strings is <code>null</code>, <code>false</code> is returned. if
* both string are <code>null</code>, <code>true</code> is returned.
*
* @param s1 first string to compare
* @param s2 second string
*
* @return <code>true</code> if strings are equal, otherwise <code>false</code>
*/
public static boolean equals(final String s1, final String s2) {
return Util.equals(s1, s2);
}
代码示例来源:origin: oblac/jodd
public Element(final Document ownerNode, final Tag tag, final boolean voidElement, final boolean selfClosed) {
super(ownerNode, NodeType.ELEMENT, Util.toString(tag.getName()));
this.voidElement = voidElement;
this.selfClosed = selfClosed;
this.rawTag = tag.isRawTag();
int attrCount = tag.getAttributeCount();
for (int i = 0; i < attrCount; i++) {
String key = Util.toString(tag.getAttributeName(i));
String value = Util.toString(tag.getAttributeValue(i));
setAttribute(key, value);
}
}
代码示例来源:origin: redisson/redisson
while (iter.hasNext()) {
Object o = iter.next();
if (equals(o, element)) {
return true;
while (enumeration.hasMoreElements()) {
Object o = enumeration.nextElement();
if (equals(o, element)) {
return true;
for (int i = 0; i < len; i++) {
Object o = Array.get(obj, i);
if (equals(o, element)) {
return true;
代码示例来源:origin: oblac/jodd
@Test
void testToString() {
assertNull(Util.toString(null));
assertEquals("abcd", Util.toString("abcd"));
assertEquals("1234", Util.toString(1234));
assertEquals("1234.0", Util.toString(1234d));
}
代码示例来源:origin: oblac/jodd
while (iter.hasNext()) {
Object o = iter.next();
if (equals(o, element)) {
return true;
while (enumeration.hasMoreElements()) {
Object o = enumeration.nextElement();
if (equals(o, element)) {
return true;
for (int i = 0; i < len; i++) {
Object o = Array.get(obj, i);
if (equals(o, element)) {
return true;
代码示例来源:origin: oblac/jodd
@Override
public void tag(final Tag tag) {
if (!insideConditionalComment) {
if (tag.nameEquals(T_LINK)) {
CharSequence type = tag.getAttributeValue("type");
if (type != null && CharSequenceUtil.equalsIgnoreCase(type, "text/css")) {
String media = Util.toString(tag.getAttributeValue("media"));
if (media == null || media.contains("screen")) {
String href = Util.toString(tag.getAttributeValue("href"));
if (cssBundleAction.acceptLink(href)) {
String link = cssBundleAction.processLink(href);
if (link != null) {
tag.setAttribute("href", link);
super.tag(tag);
}
return;
}
}
}
}
}
super.tag(tag);
}
代码示例来源:origin: oblac/jodd
@Test
void testEquals() {
Object a = new Integer(173);
Object b = new Integer(1);
Object c = new Integer(173);
assertTrue(Util.equals(a, a));
assertTrue(Util.equals(a, c));
assertTrue(Util.equals(c, a));
assertFalse(Util.equals(a, b));
assertFalse(Util.equals(b, a));
assertFalse(Util.equals(a, null));
assertFalse(Util.equals(null, a));
assertTrue(Util.equals(null, null));
}
代码示例来源:origin: oblac/jodd
@Override
public void script(final Tag tag, final CharSequence body) {
if (!insideConditionalComment) {
String src = Util.toString(tag.getAttributeValue("src"));
if (src == null) {
super.script(tag, body);
return;
}
if (jsBundleAction.acceptLink(src)) {
String link = jsBundleAction.processLink(src);
if (link != null) {
tag.setAttributeValue("src", link);
super.script(tag, body);
}
return;
}
}
super.script(tag, body);
}
代码示例来源:origin: org.jodd/jodd-core
/**
* Compares 2 strings. If one of the strings is <code>null</code>, <code>false</code> is returned. if
* both string are <code>null</code>, <code>true</code> is returned.
*
* @param s1 first string to compare
* @param s2 second string
*
* @return <code>true</code> if strings are equal, otherwise <code>false</code>
*/
public static boolean equals(final String s1, final String s2) {
return Util.equals(s1, s2);
}
代码示例来源:origin: org.jodd/jodd-lagarto
public XmlDeclaration(final Document ownerDocument, final CharSequence version, final CharSequence encoding, final CharSequence standalone) {
super(ownerDocument, NodeType.XML_DECLARATION, "xml");
this.version = Util.toString(version);
this.encoding = Util.toString(encoding);
this.standalone = Util.toString(standalone);
}
代码示例来源:origin: fivesmallq/web-data-extractor
/**
* Compares 2 strings. If one of the strings is <code>null</code>, <code>false</code> is returned. if
* both string are <code>null</code>, <code>true</code> is returned.
*
* @param s1 first string to compare
* @param s2 second string
* @return <code>true</code> if strings are equal, otherwise <code>false</code>
*/
public static boolean equals(String s1, String s2) {
return Util.equals(s1, s2);
}
代码示例来源:origin: fivesmallq/web-data-extractor
public XmlDeclaration(Document ownerDocument, CharSequence version, CharSequence encoding, CharSequence standalone) {
super(ownerDocument, NodeType.XML_DECLARATION, "xml");
this.version = Util.toString(version);
this.encoding = Util.toString(encoding);
this.standalone = Util.toString(standalone);
}
代码示例来源:origin: fivesmallq/web-data-extractor
while (iter.hasNext()) {
Object o = iter.next();
if (equals(o, element)) {
return true;
while (enumeration.hasMoreElements()) {
Object o = enumeration.nextElement();
if (equals(o, element)) {
return true;
for (int i = 0; i < len; i++) {
Object o = Array.get(obj, i);
if (equals(o, element)) {
return true;
代码示例来源:origin: fivesmallq/web-data-extractor
public void doctype(Doctype doctype) {
if (!enabled) {
return;
}
DocumentType documentType = new DocumentType(rootNode,
Util.toString(doctype.getName()),
Util.toString(doctype.getPublicIdentifier()),
Util.toString(doctype.getSystemIdentifier())
);
parentNode.addChild(documentType);
}
代码示例来源:origin: org.jodd/jodd-core
while (iter.hasNext()) {
Object o = iter.next();
if (equals(o, element)) {
return true;
while (enumeration.hasMoreElements()) {
Object o = enumeration.nextElement();
if (equals(o, element)) {
return true;
for (int i = 0; i < len; i++) {
Object o = Array.get(obj, i);
if (equals(o, element)) {
return true;
内容来源于网络,如有侵权,请联系作者删除!