Search in sources :

Example 1 with Locator2Impl

use of org.xml.sax.ext.Locator2Impl in project robovm by robovm.

the class Locator2ImplTest method testLocatorImplLocator.

public void testLocatorImplLocator() {
    Locator2Impl inner = new Locator2Impl();
    inner.setPublicId(PUB);
    inner.setSystemId(SYS);
    inner.setLineNumber(ROW);
    inner.setColumnNumber(COL);
    inner.setEncoding(ENC);
    inner.setXMLVersion(XML);
    // Ordinary case
    Locator2Impl outer = new Locator2Impl(inner);
    assertEquals(PUB, outer.getPublicId());
    assertEquals(SYS, outer.getSystemId());
    assertEquals(ROW, outer.getLineNumber());
    assertEquals(COL, outer.getColumnNumber());
    assertEquals(ENC, outer.getEncoding());
    assertEquals(XML, outer.getXMLVersion());
    // Instance of old locator
    outer = new Locator2Impl(new LocatorImpl(inner));
    assertEquals(PUB, outer.getPublicId());
    assertEquals(SYS, outer.getSystemId());
    assertEquals(ROW, outer.getLineNumber());
    assertEquals(COL, outer.getColumnNumber());
    assertEquals(null, outer.getEncoding());
    assertEquals(null, outer.getXMLVersion());
    // No locator
    try {
        outer = new Locator2Impl(null);
        fail("NullPointerException expected");
    } catch (NullPointerException e) {
    // Expected
    }
}
Also used : LocatorImpl(org.xml.sax.helpers.LocatorImpl) Locator2Impl(org.xml.sax.ext.Locator2Impl)

Example 2 with Locator2Impl

use of org.xml.sax.ext.Locator2Impl in project robovm by robovm.

the class Locator2ImplTest method testLocatorImpl.

public void testLocatorImpl() {
    Locator2Impl l = new Locator2Impl();
    assertEquals(null, l.getPublicId());
    assertEquals(null, l.getSystemId());
    assertEquals(0, l.getLineNumber());
    assertEquals(0, l.getColumnNumber());
    assertEquals(null, l.getEncoding());
    assertEquals(null, l.getXMLVersion());
}
Also used : Locator2Impl(org.xml.sax.ext.Locator2Impl)

Example 3 with Locator2Impl

use of org.xml.sax.ext.Locator2Impl in project robovm by robovm.

the class Locator2ImplTest method testSetEncodingGetEncoding.

public void testSetEncodingGetEncoding() {
    Locator2Impl l = new Locator2Impl();
    l.setEncoding(ENC);
    assertEquals(ENC, l.getEncoding());
    l.setEncoding(null);
    assertEquals(null, l.getEncoding());
}
Also used : Locator2Impl(org.xml.sax.ext.Locator2Impl)

Example 4 with Locator2Impl

use of org.xml.sax.ext.Locator2Impl in project robovm by robovm.

the class Locator2ImplTest method testSetXMLVersionGetXMLVersion.

public void testSetXMLVersionGetXMLVersion() {
    Locator2Impl l = new Locator2Impl();
    l.setXMLVersion(XML);
    assertEquals(XML, l.getXMLVersion());
    l.setXMLVersion(null);
    assertEquals(null, l.getXMLVersion());
}
Also used : Locator2Impl(org.xml.sax.ext.Locator2Impl)

Example 5 with Locator2Impl

use of org.xml.sax.ext.Locator2Impl in project intellij-community by JetBrains.

the class Psi2SaxAdapter method setLocation.

private void setLocation(PsiElement text) {
    final PsiFile psiFile = text.getContainingFile();
    final Document document = PsiDocumentManager.getInstance(text.getProject()).getDocument(psiFile);
    if (document == null) {
        return;
    }
    final VirtualFile virtualFile = psiFile.getVirtualFile();
    if (virtualFile == null) {
        return;
    }
    final Locator2Impl locator = new Locator2Impl();
    locator.setSystemId(VfsUtilCore.fixIDEAUrl(virtualFile.getUrl()));
    final int offset = text.getTextRange().getEndOffset();
    final int lineNumber = document.getLineNumber(offset);
    locator.setLineNumber(lineNumber + 1);
    locator.setColumnNumber(1 + offset - document.getLineStartOffset(lineNumber));
    myHandler.setDocumentLocator(locator);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) Document(com.intellij.openapi.editor.Document) Locator2Impl(org.xml.sax.ext.Locator2Impl)

Aggregations

Locator2Impl (org.xml.sax.ext.Locator2Impl)5 Document (com.intellij.openapi.editor.Document)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiFile (com.intellij.psi.PsiFile)1 LocatorImpl (org.xml.sax.helpers.LocatorImpl)1