当前位置: 首页>>代码示例>>Java>>正文


Java Locator2类代码示例

本文整理汇总了Java中org.xml.sax.ext.Locator2的典型用法代码示例。如果您正苦于以下问题:Java Locator2类的具体用法?Java Locator2怎么用?Java Locator2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Locator2类属于org.xml.sax.ext包,在下文中一共展示了Locator2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleStartDocument

import org.xml.sax.ext.Locator2; //导入依赖的package包/类
private void handleStartDocument(final XMLEvent event) throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return event.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return event.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return event.getLocation().getPublicId();
        }
        public String getSystemId() {
            return event.getLocation().getSystemId();
        }
        public String getXMLVersion(){
            return version;
        }
        public String getEncoding(){
            return encoding;
        }

    });
    _sax.startDocument();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:StAXEvent2SAX.java

示例2: handleStartDocument

import org.xml.sax.ext.Locator2; //导入依赖的package包/类
private void handleStartDocument() throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return staxStreamReader.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return staxStreamReader.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return staxStreamReader.getLocation().getPublicId();
        }
        public String getSystemId() {
            return staxStreamReader.getLocation().getSystemId();
        }
        public String getXMLVersion() {
            return staxStreamReader.getVersion();
        }
        public String getEncoding() {
            return staxStreamReader.getEncoding();
        }
     });
    _sax.startDocument();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:StAXStream2SAX.java

示例3: testStartElement

import org.xml.sax.ext.Locator2; //导入依赖的package包/类
@Test
public void testStartElement() throws SAXException {
  handler.startDocument();
  Locator2 locator = Mockito.mock(Locator2.class);
  handler.setDocumentLocator(locator);
  Mockito.when(locator.getLineNumber()).thenReturn(1);
  Mockito.when(locator.getColumnNumber()).thenReturn(7);
  handler.startElement("", "", "element", new AttributesImpl());
  
  assertEquals(1, handler.getElementStack().size());
  
  Element element = handler.getElementStack().pop();
  DocumentLocation location = (DocumentLocation) element.getUserData("location");
  assertEquals(1, location.getLineNumber());
  assertEquals(7, location.getColumnNumber());
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:17,代码来源:PositionalXmlHandlerTest.java

示例4: testEndElement

import org.xml.sax.ext.Locator2; //导入依赖的package包/类
@Test
public void testEndElement() throws SAXException {
  handler.startDocument();
  Locator2 locator = Mockito.mock(Locator2.class);
  handler.setDocumentLocator(locator);
  Mockito.when(locator.getLineNumber()).thenReturn(1);
  Mockito.when(locator.getColumnNumber()).thenReturn(7);
  handler.startElement("", "", "element", new AttributesImpl());
  
  assertEquals(1, handler.getElementStack().size());
  
  Mockito.when(locator.getEncoding()).thenReturn("UTF-8");
  handler.endElement("", "", "element");
  
  assertEquals(0, handler.getElementStack().size());
  
  Document document = handler.getDocument();
  Node node = document.getDocumentElement();
  DocumentLocation location = (DocumentLocation) node.getUserData("location");
  assertEquals(1, location.getLineNumber());
  assertEquals(7, location.getColumnNumber());
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:23,代码来源:PositionalXmlHandlerTest.java

示例5: testAddText

import org.xml.sax.ext.Locator2; //导入依赖的package包/类
@Test
public void testAddText() throws SAXException {
  char[] test = "test".toCharArray();
  
  handler.startDocument();
  Locator2 locator = Mockito.mock(Locator2.class);
  handler.setDocumentLocator(locator);
  Mockito.when(locator.getLineNumber()).thenReturn(1);
  Mockito.when(locator.getColumnNumber()).thenReturn(7);
  handler.startElement("", "", "element", new AttributesImpl());
  
  handler.characters(test, 0, test.length);
  handler.addText();
  
  Stack<Element> elements = handler.getElementStack();
  Node parent = elements.pop();
  NodeList childNodes = parent.getChildNodes();
  assertEquals(1, childNodes.getLength());
  assertEquals("test", childNodes.item(0).getTextContent());
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:21,代码来源:PositionalXmlHandlerTest.java

示例6: setDocumentInfo

import org.xml.sax.ext.Locator2; //导入依赖的package包/类
private void setDocumentInfo() {
    //try to set document version
    if (locator == null) return;
    try{
        _document.setXmlVersion(((Locator2)locator).getXMLVersion());
    }catch(ClassCastException e){}

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:SAX2DOM.java

示例7: setDocumentInfo

import org.xml.sax.ext.Locator2; //导入依赖的package包/类
protected void setDocumentInfo() {
    if (m_locator == null)
            return;
    try{
        String strVersion = ((Locator2)m_locator).getXMLVersion();
        if (strVersion != null)
            setVersion(strVersion);
        /*String strEncoding = ((Locator2)m_locator).getEncoding();
        if (strEncoding != null)
            setEncoding(strEncoding); */

    }catch(ClassCastException e){}
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:SerializerBase.java

示例8: setDocumentLocator

import org.xml.sax.ext.Locator2; //导入依赖的package包/类
@Override
public void setDocumentLocator(Locator locator) { 
	  if (locator instanceof Locator2) {
	    Locator2 locator2 = (Locator2) locator;
	    properties.setEL("encoding", locator2.getEncoding());
	  } 
	}
 
开发者ID:lucee,项目名称:Lucee,代码行数:8,代码来源:RSSHandler.java

示例9: setDocumentLocator

import org.xml.sax.ext.Locator2; //导入依赖的package包/类
@Override
public void setDocumentLocator(Locator locator) { 
	if (locator instanceof Locator2) {
		Locator2 locator2 = (Locator2) locator;
		root.put("encoding", locator2.getEncoding());
	} 
}
 
开发者ID:lucee,项目名称:Lucee,代码行数:8,代码来源:FeedHandler.java

示例10: setDocumentLocator

import org.xml.sax.ext.Locator2; //导入依赖的package包/类
public void setDocumentLocator (@Nullable final Locator aLocator)
{
  if (m_bTrackPosition)
  {
    m_aLocator = aLocator;
    _updatePosition ("setLocator");
    if (aLocator instanceof Locator2)
    {
      m_sSourceXMLVersion = ((Locator2) aLocator).getXMLVersion ();
      m_sSourceXMLEncoding = ((Locator2) aLocator).getEncoding ();
    }
  }
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:14,代码来源:MicroSAXHandler.java

示例11: handleStartDocument

import org.xml.sax.ext.Locator2; //导入依赖的package包/类
private void handleStartDocument(final XMLEvent event) throws SAXException {
	if (event.isStartDocument()) {
		StartDocument startDocument = (StartDocument) event;
		String xmlVersion = startDocument.getVersion();
		if (StringUtils.hasLength(xmlVersion)) {
			this.xmlVersion = xmlVersion;
		}
		if (startDocument.encodingSet()) {
			this.encoding = startDocument.getCharacterEncodingScheme();
		}
	}
	if (getContentHandler() != null) {
		final Location location = event.getLocation();
		getContentHandler().setDocumentLocator(new Locator2() {
			public int getColumnNumber() {
				return (location != null ? location.getColumnNumber() : -1);
			}
			public int getLineNumber() {
				return (location != null ? location.getLineNumber() : -1);
			}
			public String getPublicId() {
				return (location != null ? location.getPublicId() : null);
			}
			public String getSystemId() {
				return (location != null ? location.getSystemId() : null);
			}
			public String getXMLVersion() {
				return xmlVersion;
			}
			public String getEncoding() {
				return encoding;
			}
		});
		getContentHandler().startDocument();
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:37,代码来源:StaxEventXMLReader.java

示例12: handleStartDocument

import org.xml.sax.ext.Locator2; //导入依赖的package包/类
private void handleStartDocument() throws SAXException {
	if (XMLStreamConstants.START_DOCUMENT == this.reader.getEventType()) {
		String xmlVersion = this.reader.getVersion();
		if (StringUtils.hasLength(xmlVersion)) {
			this.xmlVersion = xmlVersion;
		}
		this.encoding = this.reader.getCharacterEncodingScheme();
	}
	if (getContentHandler() != null) {
		final Location location = this.reader.getLocation();
		getContentHandler().setDocumentLocator(new Locator2() {
			public int getColumnNumber() {
				return (location != null ? location.getColumnNumber() : -1);
			}
			public int getLineNumber() {
				return (location != null ? location.getLineNumber() : -1);
			}
			public String getPublicId() {
				return (location != null ? location.getPublicId() : null);
			}
			public String getSystemId() {
				return (location != null ? location.getSystemId() : null);
			}
			public String getXMLVersion() {
				return xmlVersion;
			}
			public String getEncoding() {
				return encoding;
			}
		});
		getContentHandler().startDocument();
		if (this.reader.standaloneSet()) {
			setStandalone(this.reader.isStandalone());
		}
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:37,代码来源:StaxStreamXMLReader.java

示例13: DocumentLocatorImpl

import org.xml.sax.ext.Locator2; //导入依赖的package包/类
public DocumentLocatorImpl(Locator locator)
{
  this.locator = locator;
  if (locator instanceof Locator2)
  {
    locator2 = (Locator2) locator;
  }
}
 
开发者ID:jcdarwin,项目名称:epubcheck-web,代码行数:9,代码来源:DocumentLocatorImpl.java

示例14: setDocumentLocator

import org.xml.sax.ext.Locator2; //导入依赖的package包/类
/**
 * Receive a Locator object for document events.
 */
@Override
public void setDocumentLocator(Locator locator) {
    this.locator = locator;
    if (locator instanceof Locator2) {
        this.locator2 = (Locator2) locator;
    }
}
 
开发者ID:opf-labs,项目名称:jhove2,代码行数:11,代码来源:SaxParserContentHandler.java

示例15: encodeHeader

import org.xml.sax.ext.Locator2; //导入依赖的package包/类
private void encodeHeader() throws IOException {
    encodeHeader((locator instanceof Locator2)?((Locator2)locator).getEncoding():null,
            isStandAlone,
            (locator instanceof Locator2)?((Locator2)locator).getXMLVersion():null,
            unparsedEntities, notations
            );
            
}
 
开发者ID:rpablos,项目名称:FastInfoset,代码行数:9,代码来源:SAX_FI_Encoder.java


注:本文中的org.xml.sax.ext.Locator2类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。