001: /*
002: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: * [See end of file]
004: */
005:
006: package com.hp.hpl.jena.rdf.arp.impl;
007:
008: import org.xml.sax.SAXParseException;
009:
010: import com.hp.hpl.jena.rdf.arp.states.Frame;
011:
012: public class ElementLexer extends QNameLexer {
013:
014: final private String uri;
015: final private String localName;
016: final private String qname;
017: public final boolean goodMatch;
018: public final boolean badMatch;
019:
020: public ElementLexer(Taint t, Frame f, String uri, String localName,
021: String qname, int good, int bad, boolean report_1)
022: throws SAXParseException {
023: super (f, good, bad);
024: this .uri = uri;
025: this .localName = localName;
026: this .qname = qname;
027: int match = lookup(t);
028: goodMatch = (good & match) != 0;
029: // Note: this.bad excludes good.
030: badMatch = (this .bad & match) != 0;
031:
032: if ((!(goodMatch || badMatch)) && (this .bad & E_RDF) == E_RDF) {
033: if (rdfns.equals(uri)) {
034: if (isMemberProperty(localName)) {
035: if (report_1)
036: frame.warning(t, WARN_RDF_NN_AS_TYPE, qname
037: + " is being used on a typed node.");
038: } else if (!isKnownNonMemberRDFProperty(localName)) {
039: frame
040: .warning(
041: t,
042: WARN_UNKNOWN_RDF_ELEMENT,
043: qname
044: + " is not a recognized RDF property or type.");
045:
046: }
047: }
048: }
049: }
050:
051: boolean isInRdfns(Taint me) {
052: return rdfns.equals(getUri());
053: }
054:
055: void error(Taint me, int r) throws SAXParseException {
056: frame.warning(me, r == E_LI ? ERR_LI_AS_TYPE
057: : ERR_BAD_RDF_ELEMENT, getQName()
058: + " is not allowed as an element tag here.");
059:
060: }
061:
062: void deprecatedAttribute(Taint me, int r) throws SAXParseException {
063: error(me, r);
064: }
065:
066: String getLocalName() {
067: return localName;
068: }
069:
070: String getUri() {
071: return uri;
072: }
073:
074: String getQName() {
075: return qname;
076: }
077:
078: void bagIDAttribute(Taint taintMe, int rslt)
079: throws SAXParseException {
080: error(taintMe, rslt);
081:
082: }
083:
084: }
085:
086: /*
087: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
088: * All rights reserved.
089: *
090: * Redistribution and use in source and binary forms, with or without
091: * modification, are permitted provided that the following conditions
092: * are met:
093: * 1. Redistributions of source code must retain the above copyright
094: * notice, this list of conditions and the following disclaimer.
095: * 2. Redistributions in binary form must reproduce the above copyright
096: * notice, this list of conditions and the following disclaimer in the
097: * documentation and/or other materials provided with the distribution.
098: * 3. The name of the author may not be used to endorse or promote products
099: * derived from this software without specific prior written permission.
100: *
101: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
102: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
103: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
104: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
105: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
106: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
107: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
108: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
109: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
110: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
111: */
|