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


Java Location类代码示例

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


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

示例1: testLocation

import javax.xml.stream.Location; //导入依赖的package包/类
@Test
public void testLocation() {
    String XML = "<?xml version='1.0' ?>" + "<!DOCTYPE root [\n" + "<!ENTITY intEnt 'internal'>\n" + "<!ENTITY extParsedEnt SYSTEM 'url:dummy'>\n"
            + "<!NOTATION notation PUBLIC 'notation-public-id'>\n" + "<!NOTATION notation2 SYSTEM 'url:dummy'>\n"
            + "<!ENTITY extUnparsedEnt SYSTEM 'url:dummy2' NDATA notation>\n" + "]>\n" + "<root />";

    try {
        XMLEventReader er = getReader(XML);
        XMLEvent evt = er.nextEvent(); // StartDocument
        Location loc1 = evt.getLocation();
        System.out.println("Location 1: " + loc1.getLineNumber() + "," + loc1.getColumnNumber());
        evt = er.nextEvent(); // DTD
        // loc1 should not change so its line number should still be 1
        Assert.assertTrue(loc1.getLineNumber() == 1);
        Location loc2 = evt.getLocation();
        System.out.println("Location 2: " + loc2.getLineNumber() + "," + loc2.getColumnNumber());
        evt = er.nextEvent(); // root
        System.out.println("Location 1: " + loc1.getLineNumber() + "," + loc1.getColumnNumber());
        Assert.assertTrue(loc1.getLineNumber() == 1);
        Assert.assertTrue(loc2.getLineNumber() == 7);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:Issue58Test.java

示例2: report

import javax.xml.stream.Location; //导入依赖的package包/类
public void report(String message, String errorType,
                   Object relatedInformation, Location location)
  throws XMLStreamException
{
  if (errorHandler != null)
    {
      try
        {
          errorHandler.warning(new SAXParseException(message, this));
        }
      catch (SAXException e)
        {
          XMLStreamException e2 = new XMLStreamException(e.getMessage());
          e2.initCause(e);
          throw e2;
        }
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:19,代码来源:SAXParser.java

示例3: toLocation

import javax.xml.stream.Location; //导入依赖的package包/类
private static Locator toLocation(XMLStreamReader xsr) {
    LocatorImpl loc = new LocatorImpl();
    Location in = xsr.getLocation();
    loc.setSystemId(in.getSystemId());
    loc.setPublicId(in.getPublicId());
    loc.setLineNumber(in.getLineNumber());
    loc.setColumnNumber(in.getColumnNumber());
    return loc;
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:10,代码来源:LocatableWebServiceException.java

示例4: unmarshal

import javax.xml.stream.Location; //导入依赖的package包/类
private Map<URI, Policy> unmarshal(final XMLEventReader reader, final StartElement parentElement) throws PolicyException {
    XMLEvent event = null;
    while (reader.hasNext()) {
        try {
            event = reader.peek();
            switch (event.getEventType()) {
                case XMLStreamConstants.START_DOCUMENT:
                case XMLStreamConstants.COMMENT:
                    reader.nextEvent();
                    break;

                case XMLStreamConstants.CHARACTERS:
                    processCharacters(event.asCharacters(), parentElement, map);
                    reader.nextEvent();
                    break;

                case XMLStreamConstants.END_ELEMENT:
                    processEndTag(event.asEndElement(), parentElement);
                    reader.nextEvent();
                    return map;

                case XMLStreamConstants.START_ELEMENT:
                    final StartElement element = event.asStartElement();
                    processStartTag(element, parentElement, reader, map);
                    break;

                case XMLStreamConstants.END_DOCUMENT:
                    return map;

                default:
                    throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0087_UNKNOWN_EVENT(event)));
            }
        } catch (XMLStreamException e) {
            final Location location = event == null ? null : event.getLocation();
            throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0088_FAILED_PARSE(location)), e);
        }
    }
    return map;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:ExternalAttachmentsUnmarshaller.java

示例5: getLocator

import javax.xml.stream.Location; //导入依赖的package包/类
private Locator getLocator(XMLStreamReader reader) {
    Location location = reader.getLocation();
        LocatorImpl loc = new LocatorImpl();
        loc.setSystemId(location.getSystemId());
        loc.setLineNumber(location.getLineNumber());
    return loc;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:WSDLParserExtensionFacade.java

示例6: getCurrentLocation

import javax.xml.stream.Location; //导入依赖的package包/类
public Location getCurrentLocation() {
        if (docLocator != null) {
                return new SAXLocation(docLocator);
        } else {
                return null;
        }

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

示例7: convertToStaxLocation

import javax.xml.stream.Location; //导入依赖的package包/类
Location convertToStaxLocation(final XMLLocator location){
    return new Location(){
        public int getColumnNumber(){
            return location.getColumnNumber();
        }

        public int getLineNumber(){
            return location.getLineNumber();
        }

        public String getPublicId(){
            return location.getPublicId();
        }

        public String getSystemId(){
            return location.getLiteralSystemId();
        }

        public int getCharacterOffset(){
            return location.getCharacterOffset();
        }
        public String getLocationURI(){
            return "";
        }

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

示例8: init

import javax.xml.stream.Location; //导入依赖的package包/类
protected void init(String encoding, String version, boolean standalone,Location loc) {
    setEventType(XMLStreamConstants.START_DOCUMENT);
    this.fEncodingScheam = encoding;
    this.fVersion = version;
    this.fStandalone = standalone;
    if (encoding != null && !encoding.equals(""))
        this.fEncodingSchemeSet = true;
    else {
        this.fEncodingSchemeSet = false;
        this.fEncodingScheam = "UTF-8";
    }
    this.fLocation = loc;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:StartDocumentEvent.java

示例9: setLocation

import javax.xml.stream.Location; //导入依赖的package包/类
void setLocation(Location loc){
    if (loc == null) {
        fLocation = nowhere;
    } else {
        fLocation = loc;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:DummyEvent.java

示例10: LocationImpl

import javax.xml.stream.Location; //导入依赖的package包/类
LocationImpl(Location loc){
    systemId = loc.getSystemId();
    publicId = loc.getPublicId();
    lineNo = loc.getLineNumber();
    colNo = loc.getColumnNumber();
    charOffset = loc.getCharacterOffset();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:LocationImpl.java

示例11: testSetLocation

import javax.xml.stream.Location; //导入依赖的package包/类
@Test
public void testSetLocation() {
    XMLEventFactory factory = XMLEventFactory.newInstance();
    Location loc = new MyLocation();
    factory.setLocation(loc);
    XMLEvent event = factory.createComment("some comment");
    Assert.assertEquals(event.getLocation().getLineNumber(), 15);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:XMLEventLocationTest.java

示例12: DTDImpl

import javax.xml.stream.Location; //导入依赖的package包/类
protected DTDImpl(Location location,
                  String body, Object impl, List notations, List entities)
{
  super(location);
  this.body = body;
  this.impl = impl;
  this.notations = notations;
  this.entities = entities;
}
 
开发者ID:vilie,项目名称:javify,代码行数:10,代码来源:DTDImpl.java

示例13: NotationDeclarationImpl

import javax.xml.stream.Location; //导入依赖的package包/类
protected NotationDeclarationImpl(Location location,
                                  String name, String publicId,
                                  String systemId)
{
  super(location);
  this.name = name;
  this.publicId = publicId;
  this.systemId = systemId;
}
 
开发者ID:vilie,项目名称:javify,代码行数:10,代码来源:NotationDeclarationImpl.java

示例14: StartDocumentImpl

import javax.xml.stream.Location; //导入依赖的package包/类
protected StartDocumentImpl(Location location,
                            String systemId, String encoding,
                            String xmlVersion, boolean xmlStandalone,
                            boolean standaloneDeclared,
                            boolean encodingDeclared)
{
  super(location);
  this.systemId = systemId;
  this.encoding = encoding;
  this.xmlVersion = xmlVersion;
  this.xmlStandalone = xmlStandalone;
  this.standaloneDeclared = standaloneDeclared;
  this.encodingDeclared = encodingDeclared;
}
 
开发者ID:vilie,项目名称:javify,代码行数:15,代码来源:StartDocumentImpl.java

示例15: main

import javax.xml.stream.Location; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        if (args.length == 0) {
            throw new Exception("XML file name should be specified as the first command line argument");
        }

        File xmlFile = new File(args[0]);

        //
        // instantiate the factory
        //

        XMLInputFactory factory = XMLInputFactory.newInstance();

        //
        // configure the factory
        //

        //
        // get the parser
        //

        XMLEventReader reader = factory.createXMLEventReader(new FileReader(xmlFile));

        //
        // iterate, and also manage location
        //

        while(reader.hasNext()) {

            XMLEvent e = reader.nextEvent();

            Location location = e.getLocation();

            System.out.println(
                    "[" + location.getLineNumber() + ":" + location.getColumnNumber() + "]: " +
                            e.toString());
        }
    }
 
开发者ID:NovaOrdis,项目名称:playground,代码行数:40,代码来源:Main.java


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