Search in sources :

Example 1 with Host

use of io.mola.galimatias.Host in project validator by validator.

the class LanguageDetectingChecker method startDocument.

/**
 * @see nu.validator.checker.Checker#startDocument()
 */
@Override
public void startDocument() throws SAXException {
    httpContentLangHeader = "";
    tld = "";
    htmlStartTagLocator = null;
    inBody = false;
    currentOpenElementsInDifferentLang = 0;
    currentOpenElementsWithSkipName = 0;
    nonWhitespaceCharacterCount = 0;
    elementContent = new StringBuilder();
    documentContent = new StringBuilder();
    htmlElementHasLang = false;
    htmlElementLangAttrValue = "";
    declaredLangCode = "";
    hasDir = false;
    dirAttrValue = "";
    documentContent.setLength(0);
    currentOpenElementsWithSkipName = 0;
    try {
        systemId = getDocumentLocator().getSystemId();
        if (systemId != null && systemId.startsWith("http")) {
            Host hostname = URL.parse(systemId).host();
            if (hostname != null) {
                String host = hostname.toString();
                tld = host.substring(host.lastIndexOf(".") + 1);
            }
        }
    } catch (GalimatiasParseException e) {
        throw new RuntimeException(e);
    }
}
Also used : GalimatiasParseException(io.mola.galimatias.GalimatiasParseException) Host(io.mola.galimatias.Host)

Aggregations

GalimatiasParseException (io.mola.galimatias.GalimatiasParseException)1 Host (io.mola.galimatias.Host)1