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


001:        /*
002:        	 (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:        	 [See end of file]
004:        	 $Id: StatementBase.java,v 1.13 2008/01/02 12:05:01 andy_seaborne Exp $
005:         */
006:
007:        package com.hp.hpl.jena.rdf.model.impl;
008:
009:        import com.hp.hpl.jena.graph.Node;
010:        import com.hp.hpl.jena.rdf.model.*;
011:        import com.hp.hpl.jena.shared.JenaException;
012:
013:        /**
014:         Abstract base class for StaementImpl - pulls up the stuff that doesn't depend
015:         on how statements are represented (as S/P/O or as Triples).
016:        
017:         @author hedgehog
018:         */
019:        public abstract class StatementBase {
020:            protected final ModelCom model;
021:
022:            protected StatementBase(ModelCom model) {
023:                if (model == null)
024:                    throw new JenaException("Statement models must no be null");
025:                this .model = model;
026:            }
027:
028:            public Model getModel() {
029:                return model;
030:            }
031:
032:            /**
033:             * replace this StaementImpl [ie the one of which this is the base] with (S,
034:             * P, n). Answer the new StaementImpl. Abstract here to allow methods to be
035:             * pulled up.
036:             */
037:            protected abstract StatementImpl replace(RDFNode n);
038:
039:            /**
040:             * Answer the object of this statement as a Literal, or throw a
041:             * LiteralRequiredException.
042:             */
043:            public abstract Literal getLiteral();
044:
045:            public abstract Resource getResource();
046:
047:            public abstract Resource getSubject();
048:
049:            public abstract Property getPredicate();
050:
051:            public abstract RDFNode getObject();
052:
053:            protected StatementImpl stringReplace(String s, String lang,
054:                    boolean wellFormed) {
055:                return replace(new LiteralImpl(Node.createLiteral(s, lang,
056:                        wellFormed), model));
057:            }
058:
059:            /**
060:             * "replace" the Object of this statement with the literal string value _s_.
061:             * NOTE: this is a convenience function to eliminate the use of a deprecated
062:             * constructor; when data-types are put properly into Jena, it will likely
063:             * disappear.
064:             */
065:            protected StatementImpl stringReplace(String s) {
066:                return stringReplace(s, "", false);
067:            }
068:
069:            public Statement changeLiteralObject(boolean o) {
070:                return changeObject(model.createTypedLiteral(o));
071:            }
072:
073:            public Statement changeObject(boolean o) {
074:                return stringReplace(String.valueOf(o));
075:            }
076:
077:            public Statement changeObject(long o) {
078:                return stringReplace(String.valueOf(o));
079:            }
080:
081:            public Statement changeLiteralObject(long o) {
082:                return changeObject(model.createTypedLiteral(o));
083:            }
084:
085:            public Statement changeLiteralObject(char o) {
086:                return changeObject(model.createTypedLiteral(o));
087:            }
088:
089:            public Statement changeLiteralObject(double o) {
090:                return changeObject(model.createTypedLiteral(o));
091:            }
092:
093:            public Statement changeLiteralObject(float o) {
094:                return changeObject(model.createTypedLiteral(o));
095:            }
096:
097:            public Statement changeLiteralObject(int o) {
098:                return changeObject(model.createTypedLiteral(o));
099:            }
100:
101:            public Statement changeObject(float o) {
102:                return changeObject(String.valueOf(o));
103:            }
104:
105:            public Statement changeObject(double o) {
106:                return stringReplace(String.valueOf(o));
107:            }
108:
109:            public Statement changeTypedObject(double o) {
110:                return changeObject(model.createTypedLiteral(o));
111:            }
112:
113:            public Statement changeObject(String o) {
114:                return stringReplace(String.valueOf(o));
115:            }
116:
117:            public Statement changeObject(String o, boolean wellFormed) {
118:                return stringReplace(String.valueOf(o), "", wellFormed);
119:            }
120:
121:            public Statement changeObject(String o, String l) {
122:                return stringReplace(String.valueOf(o), l, false);
123:            }
124:
125:            public Statement changeObject(String o, String l, boolean wellFormed) {
126:                return stringReplace(String.valueOf(o), l, wellFormed);
127:            }
128:
129:            public Statement changeObject(RDFNode o) {
130:                return replace(o);
131:            }
132:
133:            public Statement changeObject(Object o) {
134:                return o instanceof  RDFNode ? replace((RDFNode) o)
135:                        : stringReplace(o.toString());
136:            }
137:
138:            public boolean getBoolean() {
139:                return getLiteral().getBoolean();
140:            }
141:
142:            public byte getByte() {
143:                return getLiteral().getByte();
144:            }
145:
146:            public short getShort() {
147:                return getLiteral().getShort();
148:            }
149:
150:            public int getInt() {
151:                return getLiteral().getInt();
152:            }
153:
154:            public long getLong() {
155:                return getLiteral().getLong();
156:            }
157:
158:            public char getChar() {
159:                return getLiteral().getChar();
160:            }
161:
162:            public float getFloat() {
163:                return getLiteral().getFloat();
164:            }
165:
166:            public double getDouble() {
167:                return getLiteral().getDouble();
168:            }
169:
170:            public String getString() {
171:                return getLiteral().getLexicalForm();
172:            }
173:
174:            /**
175:             * utility: check that node is a Resource, throw otherwise
176:             */
177:            protected Resource mustBeResource(RDFNode n) {
178:                if (n instanceof  Resource)
179:                    return (Resource) n;
180:                else
181:                    throw new ResourceRequiredException(n);
182:            }
183:
184:            public String getLanguage() {
185:                return getLiteral().getLanguage();
186:            }
187:
188:            public boolean getWellFormed() {
189:                return hasWellFormedXML();
190:            }
191:
192:            public boolean hasWellFormedXML() {
193:                return getLiteral().isWellFormedXML();
194:            }
195:
196:            /**
197:             	Answer a string describing this Statement in a vagely pretty way, with the 
198:             	representations of the subject, predicate, and object in that order.
199:             */
200:            public String toString() {
201:                return "[" + getSubject().toString() + ", "
202:                        + getPredicate().toString() + ", "
203:                        + objectString(getObject()) + "]";
204:            }
205:
206:            /**
207:             	Answer a string describing <code>object</code>, quoting it if it is a literal.
208:             */
209:            protected String objectString(RDFNode object) {
210:                return object.asNode().toString(null, true);
211:            }
212:
213:        }
214:
215:        /*
216:         (c) Copyright 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP All rights
217:         reserved. Redistribution and use in source and binary forms, with or without
218:         modification, are permitted provided that the following conditions are met:
219:         1. Redistributions of source code must retain the above copyright notice,
220:         this list of conditions and the following disclaimer. 2. Redistributions in
221:         binary form must reproduce the above copyright notice, this list of
222:         conditions and the following disclaimer in the documentation and/or other
223:         materials provided with the distribution. 3. The name of the author may not
224:         be used to endorse or promote products derived from this software without
225:         specific prior written permission.
226:        
227:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
228:         WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
229:         MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
230:         EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
231:         SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
232:         PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
233:         OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
234:         WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
235:         OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
236:         ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
237:         */
w_w___w___.j_a___va__2_s__.__c___om__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.