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
}
}
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());
}
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());
}
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());
}
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);
}
Aggregations