Source Code Cross Referenced for Abbreviated.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » xmloutput » 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.xmloutput.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  (c)     Copyright 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:         *   All rights reserved.
004:         * [See end of file]
005:         *  $Id: Abbreviated.java,v 1.22 2008/01/02 12:09:33 andy_seaborne Exp $
006:         */
007:
008:        package com.hp.hpl.jena.xmloutput.impl;
009:
010:        import java.io.PrintWriter;
011:        import java.io.Writer;
012:
013:        import com.hp.hpl.jena.rdf.model.Model;
014:        import com.hp.hpl.jena.rdf.model.RDFErrorHandler;
015:        import com.hp.hpl.jena.rdf.model.Resource;
016:        import com.hp.hpl.jena.vocabulary.DAML_OIL;
017:        import com.hp.hpl.jena.vocabulary.OWL;
018:        import com.hp.hpl.jena.vocabulary.RDF;
019:        import com.hp.hpl.jena.vocabulary.RDFS;
020:        import com.hp.hpl.jena.vocabulary.RDFSyntax;
021:
022:        //Writer;
023:        //import java.io.PrintWriter;
024:
025:        /** Writes out RDF in the abbreviated syntax,  for human consumption 
026:         not only machine readable.
027:         * It is not normal to call the constructor directly, but to use
028:         * the method RDFWriterF.getWriter("RDF/XML-ABBREV").
029:         * Does not support the <code>NSPREFIXPROPBASE</code> system properties.
030:         * Use <code>setNsPrefix</code>.
031:         * For best results it is necessary to set the property 
032:         <code>"prettyTypes"</code>. See setProperty for information.
033:         @see com.hp.hpl.jena.rdf.model.RDFWriterF#getWriter(String)
034:         * @author jjc
035:         * @version  Release='$Name:  $' Revision='$Revision: 1.22 $' Date='$Date: 2008/01/02 12:09:33 $'
036:         */
037:        public class Abbreviated extends BaseXMLWriter implements 
038:                RDFErrorHandler {
039:
040:            private Resource types[] = new Resource[] {
041:                    DAML_OIL.Ontology,
042:                    OWL.Ontology,
043:                    DAML_OIL.Datatype,
044:                    //OWL.DataRange, named or orphaned dataranges unusual.      
045:                    RDFS.Datatype, DAML_OIL.Class, RDFS.Class, OWL.Class,
046:                    DAML_OIL.Property, OWL.ObjectProperty, RDF.Property,
047:                    DAML_OIL.ObjectProperty, OWL.DatatypeProperty,
048:                    DAML_OIL.DatatypeProperty, OWL.TransitiveProperty,
049:                    OWL.SymmetricProperty, OWL.FunctionalProperty,
050:                    OWL.InverseFunctionalProperty, DAML_OIL.TransitiveProperty,
051:                    DAML_OIL.UnambiguousProperty, DAML_OIL.UniqueProperty, };
052:
053:            boolean sReification;
054:
055:            boolean sIdAttr;
056:            boolean sDamlCollection;
057:            boolean sParseTypeCollectionPropertyElt;
058:            boolean sListExpand;
059:            boolean sParseTypeLiteralPropertyElt;
060:            boolean sParseTypeResourcePropertyElt;
061:            boolean sPropertyAttr;
062:
063:            boolean sResourcePropertyElt;
064:
065:            protected void unblockAll() {
066:                sDamlCollection = false;
067:                sReification = false;
068:                sResourcePropertyElt = false;
069:                sParseTypeLiteralPropertyElt = false;
070:                sParseTypeResourcePropertyElt = false;
071:                sParseTypeCollectionPropertyElt = false;
072:                sIdAttr = false;
073:                sPropertyAttr = false;
074:                sListExpand = false;
075:            }
076:
077:            {
078:                unblockAll();
079:                blockRule(RDFSyntax.propertyAttr);
080:            }
081:
082:            protected void blockRule(Resource r) {
083:                if (r.equals(RDFSyntax.sectionReification))
084:                    sReification = true;
085:                // else if (r.equals(RDFSyntax.resourcePropertyElt)) sResourcePropertyElt=true;
086:                else if (r.equals(RDFSyntax.sectionListExpand))
087:                    sListExpand = true;
088:                else if (r.equals(RDFSyntax.parseTypeLiteralPropertyElt))
089:                    sParseTypeLiteralPropertyElt = true;
090:                else if (r.equals(RDFSyntax.parseTypeResourcePropertyElt))
091:                    sParseTypeResourcePropertyElt = true;
092:                else if (r.equals(RDFSyntax.parseTypeCollectionPropertyElt))
093:                    sParseTypeCollectionPropertyElt = true;
094:                else if (r.equals(RDFSyntax.idAttr)) {
095:                    sIdAttr = true;
096:                    sReification = true;
097:                } else if (r.equals(RDFSyntax.propertyAttr))
098:                    sPropertyAttr = true;
099:                else if (r.equals(DAML_OIL.collection))
100:                    sDamlCollection = true;
101:                else {
102:                    logger.warn("Cannot block rule <" + r.getURI() + ">");
103:                }
104:            }
105:
106:            Resource[] setTypes(Resource[] propValue) {
107:                Resource[] rslt = types;
108:                types = propValue;
109:                return rslt;
110:            }
111:
112:            synchronized public void write(Model baseModel, Writer out,
113:                    String base) {
114:                if (baseModel.getGraph().getCapabilities().findContractSafe() == false) {
115:                    logger
116:                            .warn("Workaround for bugs 803804 and 858163: using RDF/XML (not RDF/XML-ABBREV) writer  for unsafe graph "
117:                                    + baseModel.getGraph().getClass());
118:                    baseModel.write(out, "RDF/XML", base);
119:                } else
120:                    super .write(baseModel, out, base);
121:            }
122:
123:            protected void writeBody(Model model, PrintWriter pw, String base,
124:                    boolean useXMLBase) {
125:                Unparser unp = new Unparser(this , base, model, pw);
126:
127:                unp.setTopLevelTypes(types);
128:                //unp.useNameSpaceDecl(nameSpacePrefices);
129:                if (useXMLBase)
130:                    unp.setXMLBase(base);
131:                unp.write();
132:            }
133:
134:            // Implemenatation of RDFErrorHandler
135:            public void error(Exception e) {
136:                errorHandler.error(e);
137:            }
138:
139:            public void warning(Exception e) {
140:                errorHandler.warning(e);
141:            }
142:
143:            public void fatalError(Exception e) {
144:                errorHandler.fatalError(e);
145:            }
146:
147:        }
148:        /*
149:         (c) Copyright 200, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
150:         All rights reserved.
151:
152:         Redistribution and use in source and binary forms, with or without
153:         modification, are permitted provided that the following conditions
154:         are met:
155:
156:         1. Redistributions of source code must retain the above copyright
157:         notice, this list of conditions and the following disclaimer.
158:
159:         2. Redistributions in binary form must reproduce the above copyright
160:         notice, this list of conditions and the following disclaimer in the
161:         documentation and/or other materials provided with the distribution.
162:
163:         3. The name of the author may not be used to endorse or promote products
164:         derived from this software without specific prior written permission.
165:
166:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
167:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
168:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
169:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
170:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
171:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
172:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
173:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
174:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
175:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
176:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.