模块 java.xml

类 LocatorImpl

java.lang.Object
org.xml.sax.helpers.LocatorImpl
所有已实现的接口:
Locator
已知子类:
Locator2Impl

public class LocatorImpl extends Object implements Locator
提供 Locator 的可选便利实现。

此类主要供应用程序编写者使用,他们可以使用它在文档解析期间的任何时候制作定位器的持久快照:

 Locator locator;
 Locator startloc;

 public void setLocator (Locator locator)
 {
     // note the locator
  this.locator = locator;
 }

 public void startDocument ()
 {
     // save the location of the start of the document
     // for future use.
  Locator startloc = new LocatorImpl(locator);
 }

通常,解析器编写者不会使用此类,因为仅在请求时提供位置信息比不断更新 Locator 对象更有效。

自从:
1.4, SAX 1.0
参见:
  • 构造方法详细信息

    • LocatorImpl

      public LocatorImpl()
      零参数构造方法。

      这通常不会有用,因为此类的主要目的是制作现有定位器的快照。

    • LocatorImpl

      public LocatorImpl(Locator  locator)
      复制构造方法。

      创建定位器当前状态的持久副本。当原始定位器发生变化时,此副本仍将保留原始值(并且可以在 DocumentHandler 方法的范围之外使用)。

      参数:
      locator - 要复制的定位器。
  • 方法详情

    • getPublicId

      public String  getPublicId()
      返回保存的公共标识符。
      指定者:
      getPublicId 在接口 Locator
      返回:
      作为字符串的公共标识符,如果没有可用的,则为 null。
      参见:
    • getSystemId

      public String  getSystemId()
      返回保存的系统标识符。
      指定者:
      getSystemId 在接口 Locator
      返回:
      作为字符串的系统标识符,如果没有可用的,则为 null。
      参见:
    • getLineNumber

      public int getLineNumber()
      返回保存的行号(从 1 开始)。
      指定者:
      getLineNumber 在接口 Locator
      返回:
      作为整数的行号,如果没有可用的,则为 -1。
      参见:
    • getColumnNumber

      public int getColumnNumber()
      返回保存的列号(从 1 开始)。
      指定者:
      getColumnNumber 在接口 Locator
      返回:
      作为整数的列号,如果没有可用的,则为 -1。
      参见:
    • setPublicId

      public void setPublicId(String  publicId)
      设置此定位器的公共标识符。
      参数:
      publicId - 新的公共标识符,如果没有可用标识符则为 null。
      参见:
    • setSystemId

      public void setSystemId(String  systemId)
      为此定位器设置系统标识符。
      参数:
      systemId - 新的系统标识符,如果没有可用的则为 null。
      参见:
    • setLineNumber

      public void setLineNumber(int lineNumber)
      设置此定位器的行号(从 1 开始)。
      参数:
      lineNumber - 行号,如果没有行号则为 -1。
      参见:
    • setColumnNumber

      public void setColumnNumber(int columnNumber)
      设置此定位器的列号(从 1 开始)。
      参数:
      columnNumber - 列号,如果没有列号则为 -1。
      参见: