mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-23 01:29:43 +01:00
minor codacy requested fixes
This commit is contained in:
@@ -13,37 +13,12 @@ import java.util.Map;
|
|||||||
* @author https://stackoverflow.com/users/823393/oldcurmudgeon
|
* @author https://stackoverflow.com/users/823393/oldcurmudgeon
|
||||||
*/
|
*/
|
||||||
public class XmlEntity {
|
public class XmlEntity {
|
||||||
|
|
||||||
/**
|
|
||||||
* Private constructor for a utility class.
|
|
||||||
*/
|
|
||||||
private XmlEntity() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a named XML entity into its HTML encoded Unicode code point.
|
|
||||||
*
|
|
||||||
* @param s the named entity (note, this should not include the leading '&'
|
|
||||||
* or trailing ';'
|
|
||||||
* @return the HTML encoded Unicode code point representation of the named
|
|
||||||
* entity
|
|
||||||
*/
|
|
||||||
public static String fromNamedReference(CharSequence s) {
|
|
||||||
if (s == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final Integer code = SPECIALS.get(s.toString());
|
|
||||||
if (code != null) {
|
|
||||||
return "&#" + code + ";";
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The map of HTML entities.
|
* The map of HTML entities.
|
||||||
*/
|
*/
|
||||||
private static final Map<String, Integer> SPECIALS;
|
private static final Map<String, Integer> SPECIALS;
|
||||||
|
|
||||||
|
//<editor-fold defaultstate="collapsed" desc="Initialize SPECIALS">
|
||||||
/**
|
/**
|
||||||
* Create a map HTML Named Entities to their numeric equivalent. Derived
|
* Create a map HTML Named Entities to their numeric equivalent. Derived
|
||||||
* from Wikipedia
|
* from Wikipedia
|
||||||
@@ -306,4 +281,30 @@ public class XmlEntity {
|
|||||||
map.put("diams", 9830);
|
map.put("diams", 9830);
|
||||||
SPECIALS = Collections.unmodifiableMap(map);
|
SPECIALS = Collections.unmodifiableMap(map);
|
||||||
}
|
}
|
||||||
|
//</editor-fold>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private constructor for a utility class.
|
||||||
|
*/
|
||||||
|
private XmlEntity() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a named XML entity into its HTML encoded Unicode code point.
|
||||||
|
*
|
||||||
|
* @param s the named entity (note, this should not include the leading '&'
|
||||||
|
* or trailing ';'
|
||||||
|
* @return the HTML encoded Unicode code point representation of the named
|
||||||
|
* entity
|
||||||
|
*/
|
||||||
|
public static String fromNamedReference(CharSequence s) {
|
||||||
|
if (s == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final Integer code = SPECIALS.get(s.toString());
|
||||||
|
if (code != null) {
|
||||||
|
return "&#" + code + ";";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,10 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.owasp.dependencycheck.xml;
|
package org.owasp.dependencycheck.xml;
|
||||||
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,6 @@ import java.io.ByteArrayInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
@@ -126,10 +121,12 @@ public class XmlInputStreamTest {
|
|||||||
InputStream stream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
|
InputStream stream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
|
||||||
XmlInputStream instance = new XmlInputStream(stream);
|
XmlInputStream instance = new XmlInputStream(stream);
|
||||||
int r = instance.read();
|
int r = instance.read();
|
||||||
|
assertEquals('t', r);
|
||||||
String expResult = "[1]-\"t\" ( 74)";
|
String expResult = "[1]-\"t\" ( 74)";
|
||||||
String result = instance.toString();
|
String result = instance.toString();
|
||||||
assertEquals(expResult, result);
|
assertEquals(expResult, result);
|
||||||
r = instance.read();
|
r = instance.read();
|
||||||
|
assertEquals('e', r);
|
||||||
expResult = "[2]-\"te\" ( 74 65)";
|
expResult = "[2]-\"te\" ( 74 65)";
|
||||||
result = instance.toString();
|
result = instance.toString();
|
||||||
assertEquals(expResult, result);
|
assertEquals(expResult, result);
|
||||||
|
|||||||
Reference in New Issue
Block a user