Added more ApiDoc methods and made eld api doc writers more complete.
This commit is contained in:
parent
d4f80f338a
commit
024865084a
27 changed files with 2119 additions and 567 deletions
|
|
@ -314,6 +314,20 @@ public final class XMLConstants {
|
|||
StringBuffer result = new StringBuffer(length);
|
||||
for (int i=0;i<length;i++) {
|
||||
char c = value.charAt(i);
|
||||
if (c=='&') {
|
||||
StringBuffer buf = new StringBuffer(length);
|
||||
int iOrg = i;
|
||||
i = charEntityLookup(i,value,buf);
|
||||
String entity = buf.toString();
|
||||
if (entity.length()>0) {
|
||||
if (charEntityAllowed(entity)) {
|
||||
result.append(entity);
|
||||
continue; // contine to next i char.
|
||||
} else {
|
||||
i = iOrg; // continue normal escape.
|
||||
}
|
||||
}
|
||||
}
|
||||
if (escapeXMLValue(c,result)) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -322,6 +336,66 @@ public final class XMLConstants {
|
|||
return result.toString();
|
||||
}
|
||||
|
||||
// TODO: make it loaded and xml and html version aware for correctness.
|
||||
static private boolean charEntityAllowed(String entity) {
|
||||
|
||||
// Hex code points
|
||||
if (entity.startsWith("&#")) {
|
||||
String hex = entity.substring(2,entity.length()-1);
|
||||
if (hex.startsWith("x")) {
|
||||
hex = hex.substring(1);
|
||||
}
|
||||
int codePoint = Integer.parseInt(hex, 16);
|
||||
return codePoint > 0; // TODO: check if code point is valid.
|
||||
}
|
||||
|
||||
// XML
|
||||
if ("<".equals(entity)) { return true; }
|
||||
if (">".equals(entity)) { return true; }
|
||||
if ("&".equals(entity)) { return true; }
|
||||
if (""e;".equals(entity)) { return true; }
|
||||
if ("'".equals(entity)) { return true; }
|
||||
|
||||
// HTML
|
||||
if ("´".equals(entity)) { return true; }
|
||||
if ("ℵ".equals(entity)) { return true; }
|
||||
if ("≈".equals(entity)) { return true; }
|
||||
if ("∠".equals(entity)) { return true; }
|
||||
if ("∗".equals(entity)) { return true; }
|
||||
if ("♣".equals(entity)) { return true; }
|
||||
if ("♦".equals(entity)) { return true; }
|
||||
if ("♥".equals(entity)) { return true; }
|
||||
if ("♠".equals(entity)) { return true; }
|
||||
// TODO: etc/etc
|
||||
if ("ÿ".equals(entity)) { return true; }
|
||||
if ("ý".equals(entity)) { return true; }
|
||||
if ("ù".equals(entity)) { return true; }
|
||||
if ("ü".equals(entity)) { return true; }
|
||||
if ("û".equals(entity)) { return true; }
|
||||
if ("ú".equals(entity)) { return true; }
|
||||
|
||||
if ("÷".equals(entity)) { return true; }
|
||||
if (" ".equals(entity)) { return true; }
|
||||
if ("®".equals(entity)) { return true; }
|
||||
if ("™".equals(entity)) { return true; }
|
||||
if ("©".equals(entity)) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
static private int charEntityLookup(int iStart,String value,StringBuffer buf) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
int iMax = 10;
|
||||
for (int i=iStart;i<value.length() && i<(iStart+iMax);i++) {
|
||||
char c = value.charAt(i);
|
||||
result.append(c);
|
||||
if (c==';') {
|
||||
buf.append(result);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return iStart; // not found continue escaping.
|
||||
}
|
||||
|
||||
static public String escapeCharactersCdata(String value,String replaceCdataStart,String replaceCdataEnd) {
|
||||
value = value.replaceAll(CDATA_START_REGEX, replaceCdataStart);
|
||||
value = value.replaceAll(CDATA_END_REGEX, replaceCdataEnd);
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ public class AbstractContentWriterHandler implements ContentHandler {
|
|||
}
|
||||
|
||||
// move or remove ?
|
||||
public void charactersRaw(String text) throws SAXException {
|
||||
protected void charactersRaw(String text) throws SAXException {
|
||||
if (text==null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import java.io.BufferedReader;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue