return null;
}
public void checkValid(CharSequence literal) throws DatatypeException {
// TODO Find out if it is safe to put this in a field
IRIFactory fac = new IRIFactory();
fac.shouldViolation(true, false);
fac.securityViolation(true, false);
fac.dnsViolation(true, false);
fac.mintingViolation(false, false);
fac.useSpecificationIRI(true);
fac.useSchemeSpecificRules("http", true);
fac.useSchemeSpecificRules("https", true);
fac.useSchemeSpecificRules("ftp", true);
fac.useSchemeSpecificRules("mailto", true); // XXX broken
fac.useSchemeSpecificRules("file", true);
fac.useSchemeSpecificRules("data", true); // XXX broken
// XXX javascript?
// fac.setQueryCharacterRestrictions(false);
IRI iri;
boolean data = false;
try {
CharSequencePair pair = splitScheme(literal);
if (pair == null) {
// no scheme or scheme is private
iri = fac.construct(trimHtmlSpaces(literal.toString()));
} else {
CharSequence scheme = pair.getHead();
CharSequence tail = pair.getTail();
if (isWellKnown(scheme)) {
iri = fac.construct(trimHtmlSpaces(literal.toString()));
} else if ("javascript".contentEquals(scheme)) {
// StringBuilder sb = new StringBuilder(2 +
// literal.length());
// sb.append("x-").append(literal);
// iri = fac.construct(sb.toString());
iri = null; // Don't bother user with generic IRI syntax
Reader reader = new BufferedReader(
new Utf8PercentDecodingReader(new StringReader(
"function(event){" + tail.toString() + "}")));
// XXX CharSequenceReader
reader.mark(1);
int c = reader.read();
if (c != 0xFEFF) {
reader.reset();
}
try {
Context context = ContextFactory.getGlobal().enterContext();
context.setOptimizationLevel(0);
context.setLanguageVersion(Context.VERSION_1_6);
// -1 for lineno arg prevents Rhino from appending
// "(unnamed script#1)" to all error messages
context.compileReader(reader, null, -1, null);
} finally {
Context.exit();
}
} else if ("data".contentEquals(scheme)) {
data = true;
iri = fac.construct(trimHtmlSpaces(literal.toString()));
} else if (isHttpAlias(scheme)) {
StringBuilder sb = new StringBuilder(5 + tail.length());
sb.append("http:").append(tail);
iri = fac.construct(trimHtmlTrailingSpaces(sb.toString()));
} else {
StringBuilder sb = new StringBuilder(2 + literal.length());
sb.append("x-").append(literal);
iri = fac.construct(trimHtmlTrailingSpaces(sb.toString()));
}
}
} catch (IRIException e) {
Violation v = e.getViolation();
/*