Source Code Cross Referenced for QNameLexer.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » rdf » arp » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » RSS RDF » Jena 2.5.5 » com.hp.hpl.jena.rdf.arp.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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 java.util.HashSet;
009:        import java.util.Set;
010:
011:        import org.xml.sax.SAXParseException;
012:
013:        import com.hp.hpl.jena.rdf.arp.ARPErrorNumbers;
014:        import com.hp.hpl.jena.rdf.arp.states.Frame;
015:
016:        abstract public class QNameLexer implements  Names, ARPErrorNumbers {
017:            final int bad;
018:            final int select;
019:            final Frame frame;
020:
021:            public QNameLexer(Frame f, int good, int bad) {
022:                bad &= ~good;
023:                this .bad = bad;
024:                this .select = good | bad;
025:                this .frame = f;
026:            }
027:
028:            private int xml(String wanted, int fl) {
029:                return (fl & select) == fl && wanted.equals(getLocalName())
030:                        && getUri().equals(xmlns) ? fl : 0;
031:            }
032:
033:            abstract boolean isInRdfns(Taint taintMe) throws SAXParseException;
034:
035:            abstract void error(Taint taintMe, int rslt)
036:                    throws SAXParseException;
037:
038:            abstract void deprecatedAttribute(Taint me, int rslt)
039:                    throws SAXParseException;
040:
041:            abstract String getLocalName();
042:
043:            abstract String getUri();
044:
045:            abstract String getQName();
046:
047:            private int rdf(Taint taintMe, String wanted, int fl)
048:                    throws SAXParseException {
049:                if ((fl & select) == fl && wanted.equals(getLocalName())) {
050:                    if (isInRdfns(taintMe))
051:                        return fl;
052:                    if (getQName().toLowerCase().startsWith("rdf:"))
053:                        frame
054:                                .warning(
055:                                        taintMe,
056:                                        WARN_NOT_RDF_NAMESPACE,
057:                                        getQName()
058:                                                + " is not special. "
059:                                                + "The namespace binding of the RDF namespace is incorrect. It should be <"
060:                                                + rdfns + "> not <" + getUri()
061:                                                + ">");
062:                }
063:                return 0;
064:            }
065:
066:            int lookup(Taint taintMe) throws SAXParseException {
067:                int rslt = lookupNoMsg(taintMe);
068:                if ((rslt & bad) != 0) {
069:                    switch (rslt) {
070:                    case A_DEPRECATED:
071:                        deprecatedAttribute(taintMe, rslt);
072:                        break;
073:                    case A_BAGID:
074:                        bagIDAttribute(taintMe, rslt);
075:                        break;
076:                    default:
077:                        error(taintMe, rslt);
078:                    }
079:                }
080:                return rslt;
081:            }
082:
083:            abstract void bagIDAttribute(Taint taintMe, int rslt)
084:                    throws SAXParseException;
085:
086:            private int lookupNoMsg(Taint taintMe) throws SAXParseException {
087:                char firstChar;
088:                try {
089:                    firstChar = getLocalName().charAt(0);
090:                } catch (StringIndexOutOfBoundsException e) {
091:                    // Yes this really happens with the DOM one.
092:                    // How disgusting.
093:                    // When xmlns="eg:a"
094:                    // xmlns is the prefix ...
095:                    //            System.err.println(getUri());
096:                    if (this .getUri().equals(xmlnsns))
097:                        return A_XMLNS;
098:                    throw e;
099:                }
100:                switch (firstChar) {
101:                case 'b': /* base bagID */
102:                    switch (getLocalName().length()) {
103:                    case 4:
104:                        return xml("base", A_XMLBASE);
105:                    case 5:
106:                        return rdf(taintMe, "bagID", A_BAGID);
107:                    }
108:                    break;
109:                case 'l': /* lang  li */
110:                    switch (getLocalName().length()) {
111:                    case 2:
112:                        return rdf(taintMe, "li", E_LI);
113:                    case 4:
114:                        return xml("lang", A_XMLLANG);
115:                    }
116:                    break;
117:                case 's': /* space */
118:                    return xml("space", A_XML_OTHER);
119:                case 'i': /* space */
120:                    return xml("id", A_XML_OTHER);
121:                case 'I': /* ID */
122:                    return rdf(taintMe, "ID", A_ID);
123:                case 'n': /* nodeID */
124:                    return rdf(taintMe, "nodeID", A_NODEID);
125:                case 'a': /* about aboutEach aboutEachPrefix */
126:                    switch (getLocalName().length()) {
127:                    case 5:
128:                        return rdf(taintMe, "about", A_ABOUT);
129:                    case 9:
130:                        return rdf(taintMe, "aboutEach", A_DEPRECATED);
131:                    case 15:
132:                        return rdf(taintMe, "aboutEachPrefix", A_DEPRECATED);
133:                    }
134:                    break;
135:                case 'r': /* resource */
136:                    return rdf(taintMe, "resource", A_RESOURCE);
137:                case 'R': /* resource */
138:                    return rdf(taintMe, "RDF", E_RDF);
139:                case 'd': /* datatype */
140:                    return rdf(taintMe, "datatype", A_DATATYPE);
141:                case 't': /* type */
142:                    return rdf(taintMe, "type", A_TYPE);
143:                case 'p': /* parseType */
144:                    return rdf(taintMe, "parseType", A_PARSETYPE);
145:                case 'D': /* Description */
146:                    return rdf(taintMe, "Description", E_DESCRIPTION);
147:                }
148:                return 0;
149:            }
150:
151:            //    static final Set rdfnames = new HashSet();
152:            //    static {
153:            //        rdfnames.add("Description");
154:            //        rdfnames.add("RDF");
155:            //        rdfnames.add("li");
156:            //    }
157:
158:            static final Set knownRDFProperties = new HashSet();
159:
160:            static final Set knownRDFTypes = knownRDFProperties;
161:            static {
162:                knownRDFTypes.add("Bag");
163:                knownRDFTypes.add("Seq");
164:                knownRDFTypes.add("Alt");
165:                knownRDFTypes.add("List");
166:                knownRDFTypes.add("XMLLiteral");
167:                knownRDFTypes.add("Property");
168:                knownRDFProperties.add("type");
169:                knownRDFTypes.add("Statement");
170:                knownRDFProperties.add("subject");
171:                knownRDFProperties.add("predicate");
172:                knownRDFProperties.add("object");
173:                knownRDFProperties.add("value");
174:                knownRDFProperties.add("first");
175:                knownRDFProperties.add("rest");
176:                // not strictly true.
177:                knownRDFProperties.add("nil");
178:            }
179:
180:            //    static final Set knownBadRDFNames = new HashSet();
181:            //    static {
182:            //        knownBadRDFNames.add("ID");
183:            //        knownBadRDFNames.add("about");
184:            //        knownBadRDFNames.add("aboutEach");
185:            //        knownBadRDFNames.add("aboutEachPrefix");
186:            //        knownBadRDFNames.add("resource");
187:            //        knownBadRDFNames.add("bagID");
188:            //        knownBadRDFNames.add("parseType");
189:            //        knownBadRDFNames.add("datatype");
190:            //        knownBadRDFNames.add("li");
191:            //        knownBadRDFNames.add("type");
192:            //        knownBadRDFNames.add("Description");
193:            //        knownBadRDFNames.add("nodeID");
194:            //    }
195:
196:            protected static boolean isMemberProperty(String name) {
197:                if (name.startsWith("_")) {
198:                    String number = name.substring(1);
199:                    if (number.startsWith("-") || number.startsWith("0"))
200:                        return false;
201:                    try {
202:                        Integer.parseInt(number);
203:                        return true;
204:                    } catch (NumberFormatException e) {
205:                        try {
206:                            // It might be > Integer.MAX_VALUE
207:                            new java.math.BigInteger(number);
208:                            return true;
209:                        } catch (NumberFormatException ee) {
210:                            return false;
211:                        }
212:                    }
213:                }
214:                return false;
215:            }
216:
217:            static public boolean isKnownRDFProperty(String name) {
218:                return knownRDFProperties.contains(name)
219:                        || isMemberProperty(name);
220:            }
221:
222:            static public boolean isKnownNonMemberRDFProperty(String name) {
223:                return knownRDFProperties.contains(name);
224:            }
225:
226:        }
227:
228:        /*
229:         *  (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
230:         *  All rights reserved.
231:         *
232:         * Redistribution and use in source and binary forms, with or without
233:         * modification, are permitted provided that the following conditions
234:         * are met:
235:         * 1. Redistributions of source code must retain the above copyright
236:         *    notice, this list of conditions and the following disclaimer.
237:         * 2. Redistributions in binary form must reproduce the above copyright
238:         *    notice, this list of conditions and the following disclaimer in the
239:         *    documentation and/or other materials provided with the distribution.
240:         * 3. The name of the author may not be used to endorse or promote products
241:         *    derived from this software without specific prior written permission.
242:         *
243:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
244:         * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
245:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
246:         * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
247:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
248:         * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
249:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
250:         * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
251:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
252:         * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
253:         */
w_w__w.__j___a___v__a__2___s_._com_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.