Java Code Examples for org.xml.sax.Locator

The following examples show how to use org.xml.sax.Locator. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: TencentKona-8   Source File: Element.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Define its content model.
 */
void define(short contentModelType, Term contentModel, Locator locator) {
    assert this.contentModel==null; // may not be called twice
    this.contentModelType = contentModelType;
    this.contentModel = contentModel;
    this.locator = locator;
    contentModel.normalize(normalizedBlocks,false);

    for( Block b : normalizedBlocks ) {
        if(b.isRepeated || b.elements.size()>1) {
            for( Element e : b.elements ) {
                owner.getOrCreateElement(e.name).mustBeClass = true;
            }
        }
    }
}
 
Example 2
Source Project: jdk8u60   Source File: CPropertyInfo.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected CPropertyInfo(String name, boolean collection, XSComponent source,
                        CCustomizations customizations, Locator locator) {
    this.publicName = name;
    String n = null;

    Model m = Ring.get(Model.class);
    if (m != null) {
        n = m.getNameConverter().toVariableName(name);
    } else {
        n = NameConverter.standard.toVariableName(name);
    }

    if(!JJavaName.isJavaIdentifier(n))
        n = '_'+n;  // avoid colliding with the reserved names like 'abstract'.
    this.privateName = n;

    this.isCollection = collection;
    this.locator = locator;
    if(customizations==null)
        this.customizations = CCustomizations.EMPTY;
    else
        this.customizations = customizations;
    this.source = source;
}
 
Example 3
public ParsedPattern endGrammar(Location loc, Annotations anno) throws BuildException {
    for (Enumeration e = defines.keys();
            e.hasMoreElements();) {
        String name = (String) e.nextElement();
        RefPattern rp = (RefPattern) defines.get(name);
        if (rp.getPattern() == null) {
            sb.error("reference_to_undefined", name, rp.getRefLocator());
            rp.setPattern(sb.pb.makeError());
        }
    }
    Pattern start = startRef.getPattern();
    if (start == null) {
        sb.error("missing_start_element", (Locator) loc);
        start = sb.pb.makeError();
    }
    return start;
}
 
Example 4
@Override
public Object[] adaptArguments(Object[] arguments) {
	for (int i = 0; i < arguments.length; i++) {
		if (arguments[i] instanceof Locator) {
			arguments[i] = null;
		}
	}
	return arguments;
}
 
Example 5
Source Project: jdk8u60   Source File: XMLFilterImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Filter a new document locator event.
 *
 * @param locator The document locator.
 */
public void setDocumentLocator (Locator locator)
{
    this.locator = locator;
    if (contentHandler != null) {
        contentHandler.setDocumentLocator(locator);
    }
}
 
Example 6
Source Project: TencentKona-8   Source File: SchemaImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public SchemaImpl(SchemaSetImpl _parent, Locator loc, String tns) {
    if (tns == null)
        // the empty string must be used.
        throw new IllegalArgumentException();
    this.targetNamespace = tns;
    this.parent = _parent;
    this.locator = loc;
}
 
Example 7
Source Project: jdk8u60   Source File: Locator2Impl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Copy an existing Locator or Locator2 object.
 * If the object implements Locator2, values of the
 * <em>encoding</em> and <em>version</em>strings are copied,
 * otherwise they set to <em>null</em>.
 *
 * @param locator The existing Locator object.
 */
public Locator2Impl (Locator locator)
{
    super (locator);
    if (locator instanceof Locator2) {
        Locator2    l2 = (Locator2) locator;

        version = l2.getXMLVersion ();
        encoding = l2.getEncoding ();
    }
}
 
Example 8
Source Project: jdk8u60   Source File: elementDeclBody.java    License: GNU General Public License v2.0 5 votes vote down vote up
public elementDeclBody(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie, Locator _locator, boolean _isGlobal) {
    super(source, parent, cookie);
    $runtime = runtime;
    this.locator = _locator;
    this.isGlobal = _isGlobal;
    $_ngcc_current_state = 48;
}
 
Example 9
public attributeDeclBody(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie, Locator _locator, boolean _isLocal, String _defaultValue, String _fixedValue) {
    super(source, parent, cookie);
    $runtime = runtime;
    this.locator = _locator;
    this.isLocal = _isLocal;
    this.defaultValue = _defaultValue;
    this.fixedValue = _fixedValue;
    $_ngcc_current_state = 13;
}
 
Example 10
Source Project: openjdk-jdk8u   Source File: Util.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Compares if two {@link Locator}s point to the exact same position.
 */
public static boolean equals(Locator lhs, Locator rhs) {
    return lhs.getLineNumber()==rhs.getLineNumber()
    && lhs.getColumnNumber()==rhs.getColumnNumber()
    && equals(lhs.getSystemId(),rhs.getSystemId())
    && equals(lhs.getPublicId(),rhs.getPublicId());
}
 
Example 11
DelayedRef( PatcherManager _manager, Locator _source, SchemaImpl _schema, UName _name ) {

        this.schema = _schema.getRoot();
        this.manager = _manager;
        this.name = _name;
        this.source = _source;

        if(name==null)  throw new InternalError();

        manager.addPatcher(this);
    }
 
Example 12
Source Project: openjdk-jdk8u   Source File: modelGroupBody.java    License: GNU General Public License v2.0 5 votes vote down vote up
public modelGroupBody(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie, Locator _locator, String _compositorName) {
    super(source, parent, cookie);
    $runtime = runtime;
    this.locator = _locator;
    this.compositorName = _compositorName;
    $_ngcc_current_state = 6;
}
 
Example 13
Source Project: TencentKona-8   Source File: CEnumLeafInfo.java    License: GNU General Public License v2.0 5 votes vote down vote up
public CEnumLeafInfo(Model model,
                     QName typeName,
                     CClassInfoParent container,
                     String shortName,
                     CNonElement base,
                     Collection<CEnumConstant> _members,
                     XSComponent source,
                     CCustomizations customizations,
                     Locator _sourceLocator) {
    this.model = model;
    this.parent = container;
    this.shortName = model.allocator.assignClassName(parent,shortName);
    this.base = base;
    this.members = _members;
    this.source = source;
    if(customizations==null)
        customizations = CCustomizations.EMPTY;
    this.customizations = customizations;
    this.sourceLocator = _sourceLocator;
    this.typeName = typeName;

    for( CEnumConstant mem : members )
        mem.setParent(this);

    model.add(this);

    // TODO: can we take advantage of the fact that enum can be XmlRootElement?
}
 
Example 14
/**
 * Implements org.xml.sax.ContentHandler.setDocumentLocator()
 * Receive an object for locating the origin of SAX document events.
 */
@Override
public void setDocumentLocator(Locator locator) {
    _locator = locator;

    if (_handler != null) {
        _handler.setDocumentLocator(locator);
    }
}
 
Example 15
Source Project: TencentKona-8   Source File: Util.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Compares if two {@link Locator}s point to the exact same position.
 */
public static boolean equals(Locator lhs, Locator rhs) {
    return lhs.getLineNumber()==rhs.getLineNumber()
    && lhs.getColumnNumber()==rhs.getColumnNumber()
    && equals(lhs.getSystemId(),rhs.getSystemId())
    && equals(lhs.getPublicId(),rhs.getPublicId());
}
 
Example 16
private String printLocator(Locator loc) {
    if( loc==null )     return "";

    int line = loc.getLineNumber();
    String sysId = loc.getSystemId();
    if(sysId==null)     sysId = Messages.format(Messages.MSG_UNKNOWN_FILE);

    if( line!=-1 )
        return Messages.format( Messages.MSG_LINE_X_OF_Y,
                Integer.toString(line), sysId );
    else
        return sysId;
}
 
Example 17
Source Project: openjdk-jdk9   Source File: DAnnotation.java    License: GNU General Public License v2.0 5 votes vote down vote up
public Attribute(String ns, String localName, String prefix, String value, Locator loc) {
    this.ns = ns;
    this.localName = localName;
    this.prefix = prefix;
    this.value = value;
    this.loc = loc;
}
 
Example 18
public ParsedPattern makeParentRef(String name, Location loc, Annotations anno) throws BuildException {
    // TODO: do this check by the caller
    if (parent == null) {
        sb.error("parent_ref_outside_grammar", (Locator) loc);
        return sb.makeErrorPattern();
    }
    return parent.makeRef(name, loc, anno);
}
 
Example 19
Source Project: Tomcat7.0.67   Source File: Digester.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the document locator associated with our parser.
 *
 * @param locator The new locator
 */
@Override
public void setDocumentLocator(Locator locator) {

    if (saxLog.isDebugEnabled()) {
        saxLog.debug("setDocumentLocator(" + locator + ")");
    }

    this.locator = locator;

}
 
Example 20
public Definitions(AbstractDocument document, Locator locator) {
    super(locator);
    _document = document;
    _bindings = new ArrayList();
    _imports = new ArrayList();
    _messages = new ArrayList();
    _portTypes = new ArrayList();
    _services = new ArrayList();
    _importedNamespaces = new HashSet();
    _helper = new ExtensibilityHelper();
}
 
Example 21
Source Project: jdk8u60   Source File: SimpleTypeImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
SimpleTypeImpl(
    SchemaDocumentImpl _parent,
    AnnotationImpl _annon,
    Locator _loc,
    ForeignAttributesImpl _fa,
    String _name,
    boolean _anonymous,
    Set<XSVariety> finalSet,
    Ref.SimpleType _baseType) {

    super(_parent, _annon, _loc, _fa, _parent.getTargetNamespace(), _name, _anonymous);

    this.baseType = _baseType;
    this.finalSet = finalSet;
}
 
Example 22
Source Project: JDKSourceCode1.8   Source File: ParserAdapter.java    License: MIT License 5 votes vote down vote up
/**
 * Adapter implementation method; do not call.
 * Adapt a SAX1 document locator event.
 *
 * @param locator A document locator.
 * @see org.xml.sax.ContentHandler#setDocumentLocator
 */
public void setDocumentLocator (Locator locator)
{
    this.locator = locator;
    if (contentHandler != null) {
        contentHandler.setDocumentLocator(locator);
    }
}
 
Example 23
Source Project: openjdk-jdk8u-backup   Source File: Binding.java    License: GNU General Public License v2.0 4 votes vote down vote up
public Binding(Defining defining, Locator locator, ErrorReceiver receiver) {
    super(defining, locator, receiver);
    _operations = new ArrayList();
    _helper = new ExtensibilityHelper();
}
 
Example 24
private void warning(String key, Locator loc) throws SAXException {
    warning(new SAXParseException(localizer.message(key), loc));
}
 
Example 25
Source Project: openjdk-jdk9   Source File: ErrorReceiver.java    License: GNU General Public License v2.0 4 votes vote down vote up
public final void error( Locator loc, String msg, Exception e ) {
    error( new SAXParseException2(msg,loc,e) );
}
 
Example 26
public void yyevent(SaxEvent saxtoken) throws SAXException {
  if (accepted) {
    throw new SAXException("yyevent called after parser has accepted");
  }

  SaxEventType event = saxtoken.eventtype;
  String name = saxtoken.name;
  int yytoken = 0;
  Lexeme element = null;
  Lexeme attr = null;

  element = elementmap.get(name);

  switch (event) {

    case STARTELEMENT:
      if (element == null) {// undefined
        yytoken = UNKNOWN_ELEMENT_;
        break;
      }
      yytoken = element.open;
      if (yytoken == OTHERXML_) {
        otherxml = true;
        textok = true;
      } else if (!otherxml && yytoken == VALUE_)
        textok = true;
      break;

    case ATTRIBUTE:
      String lcname = name.toLowerCase();
      attr = attributemap.get(lcname);
      if (attr == null) {
        if (lcname.startsWith(SPECIALATTRPREFIX))
          yytoken = ATTR_SPECIAL;
        else
          yytoken = UNKNOWN_ATTR;
      } else
        yytoken = attr.atoken;
      break;

    case ENDELEMENT:
      if (element == null) {// undefined
        yytoken = _UNKNOWN_ELEMENT;
        break;
      }
      yytoken = element.close;
      if (yytoken == _OTHERXML) {
        otherxml = false;
        textok = false;
      } else if (!otherxml && yytoken == _VALUE)
        textok = false;
      break;

    case CHARACTERS:
      if (!textok)
        return; // ignore
      yytoken = TEXT;
      break;

    case ENDDOCUMENT:
      yytoken = EOF;
      break;

    default:
      return; // ignore

  } // switch

  int status = 0;
  try {
    Locator loc = getLocator();
    Dap4BisonParser parser = (Dap4BisonParser) this;
    // Bison.Position pos = new Bison.Position(loc);
    // Dap4BisonParser.Location yyloc = parser.new Location(pos);
    status = parser.push_parse(yytoken, saxtoken);
  } catch (Exception e) {
    throw new SAXException(e);
  }
  if (status == YYABORT)
    throw new SAXException("YYABORT");
  else if (status == YYACCEPT)
    accepted = true;
}
 
Example 27
Source Project: TencentKona-8   Source File: WildcardImpl.java    License: GNU General Public License v2.0 4 votes vote down vote up
protected WildcardImpl( SchemaDocumentImpl owner, AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa, int _mode ) {
    super(owner,_annon,_loc,_fa);
    this.mode = _mode;
}
 
Example 28
Source Project: TencentKona-8   Source File: SchemaParser.java    License: GNU General Public License v2.0 4 votes vote down vote up
private void error(String key, String arg, Locator loc) throws SAXException {
    error(new SAXParseException(localizer.message(key, arg), loc));
}
 
Example 29
private void warning(String key, String arg1, String arg2, Locator loc)
        throws SAXException {
    warning(new SAXParseException(localizer.message(key, arg1, arg2), loc));
}
 
Example 30
Source Project: spring-analysis-note   Source File: DomContentHandler.java    License: MIT License 4 votes vote down vote up
@Override
public void setDocumentLocator(Locator locator) {
}