Source Code Cross Referenced for ResourceImpl.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 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:          [See end of file]
004:          $Id: ResourceImpl.java,v 1.47 2008/01/02 12:04:56 andy_seaborne Exp $
005:         */
006:
007:        package com.hp.hpl.jena.rdf.model.impl;
008:
009:        import com.hp.hpl.jena.rdf.model.*;
010:        import com.hp.hpl.jena.datatypes.RDFDatatype;
011:        import com.hp.hpl.jena.enhanced.*;
012:
013:        import com.hp.hpl.jena.graph.*;
014:
015:        /** An implementation of Resource.
016:         *
017:         * @author  bwm
018:         * @version  Release='$Name:  $' Revision='$Revision: 1.47 $' Date='$Date: 2008/01/02 12:04:56 $'
019:         */
020:
021:        public class ResourceImpl extends EnhNode implements  Resource {
022:
023:            final static public Implementation factory = new Implementation() {
024:                public boolean canWrap(Node n, EnhGraph eg) {
025:                    return !n.isLiteral();
026:                }
027:
028:                public EnhNode wrap(Node n, EnhGraph eg) {
029:                    if (n.isLiteral())
030:                        throw new ResourceRequiredException(n);
031:                    return new ResourceImpl(n, eg);
032:                }
033:            };
034:            final static public Implementation rdfNodeFactory = new Implementation() {
035:                public boolean canWrap(Node n, EnhGraph eg) {
036:                    return true;
037:                }
038:
039:                public EnhNode wrap(Node n, EnhGraph eg) {
040:                    if (n.isURI() || n.isBlank())
041:                        return new ResourceImpl(n, eg);
042:                    if (n.isLiteral())
043:                        return new LiteralImpl(n, eg);
044:                    return null;
045:                }
046:            };
047:
048:            /**
049:                the master constructor: make a new Resource in the given model,
050:                rooted in the given node.
051:            
052:                NOT FOR PUBLIC USE - used in ModelCom [and ContainerImpl]
053:             */
054:            public ResourceImpl(Node n, ModelCom m) {
055:                super (n, m);
056:            }
057:
058:            /** Creates new ResourceImpl */
059:
060:            public ResourceImpl() {
061:                this ((ModelCom) null);
062:            }
063:
064:            public ResourceImpl(ModelCom m) {
065:                this (fresh(null), m);
066:            }
067:
068:            public ResourceImpl(Node n, EnhGraph m) {
069:                super (n, m);
070:            }
071:
072:            public ResourceImpl(String uri) {
073:                super (fresh(uri), null);
074:            }
075:
076:            public ResourceImpl(String nameSpace, String localName) {
077:                super (Node.createURI(nameSpace + localName), null);
078:            }
079:
080:            public ResourceImpl(AnonId id) {
081:                this (id, null);
082:            }
083:
084:            public ResourceImpl(AnonId id, ModelCom m) {
085:                this (Node.createAnon(id), m);
086:            }
087:
088:            public ResourceImpl(String uri, ModelCom m) {
089:                this (fresh(uri), m);
090:            }
091:
092:            public ResourceImpl(Resource r, ModelCom m) {
093:                this (r.asNode(), m);
094:            }
095:
096:            public ResourceImpl(String nameSpace, String localName, ModelCom m) {
097:                this (Node.createURI(nameSpace + localName), m);
098:            }
099:
100:            public Object visitWith(RDFVisitor rv) {
101:                return isAnon() ? rv.visitBlank(this , getId()) : rv.visitURI(
102:                        this , getURI());
103:            }
104:
105:            public RDFNode inModel(Model m) {
106:                return getModel() == m ? this  : isAnon() ? m
107:                        .createResource(getId())
108:                        : asNode().isConcrete() == false ? ((ModelCom) m)
109:                                .getRDFNode(asNode()) : m
110:                                .createResource(getURI());
111:            }
112:
113:            private static Node fresh(String uri) {
114:                return uri == null ? Node.createAnon() : Node.createURI(uri);
115:            }
116:
117:            public Node getNode() {
118:                return asNode();
119:            }
120:
121:            public AnonId getId() {
122:                return asNode().getBlankNodeId();
123:            }
124:
125:            public String getURI() {
126:                return isAnon() ? null : node.getURI();
127:            }
128:
129:            public String getNameSpace() {
130:                return isAnon() ? null : node.getNameSpace();
131:            }
132:
133:            public String getLocalName() {
134:                return isAnon() ? null : node.getLocalName();
135:            }
136:
137:            public boolean hasURI(String uri) {
138:                return node.hasURI(uri);
139:            }
140:
141:            public String toString() {
142:                return asNode().toString();
143:            }
144:
145:            protected ModelCom mustHaveModel() {
146:                ModelCom model = getModelCom();
147:                if (model == null)
148:                    throw new HasNoModelException(this );
149:                return model;
150:            }
151:
152:            public Statement getRequiredProperty(Property p) {
153:                return mustHaveModel().getRequiredProperty(this , p);
154:            }
155:
156:            public Statement getProperty(Property p) {
157:                return mustHaveModel().getProperty(this , p);
158:            }
159:
160:            public StmtIterator listProperties(Property p) {
161:                return mustHaveModel().listStatements(this , p, (RDFNode) null);
162:            }
163:
164:            public StmtIterator listProperties() {
165:                return mustHaveModel().listStatements(this , null,
166:                        (RDFNode) null);
167:            }
168:
169:            /**
170:             * @deprecated Use {@link #addLiteral(Property,boolean)} instead
171:             */
172:            public Resource addTypedProperty(Property p, boolean o) {
173:                return addLiteral(p, o);
174:            }
175:
176:            public Resource addLiteral(Property p, boolean o) {
177:                ModelCom m = mustHaveModel();
178:                m.add(this , p, m.createTypedLiteral(o));
179:                return this ;
180:            }
181:
182:            public Resource addProperty(Property p, long o) {
183:                mustHaveModel().addLiteral(this , p, o);
184:                return this ;
185:            }
186:
187:            public Resource addLiteral(Property p, long o) {
188:                Model m = mustHaveModel();
189:                m.add(this , p, m.createTypedLiteral(o));
190:                return this ;
191:            }
192:
193:            public Resource addLiteral(Property p, char o) {
194:                ModelCom m = mustHaveModel();
195:                m.add(this , p, m.createTypedLiteral(o));
196:                return this ;
197:            }
198:
199:            public Resource addProperty(Property p, float o) {
200:                mustHaveModel().addLiteral(this , p, o);
201:                return this ;
202:            }
203:
204:            public Resource addProperty(Property p, double o) {
205:                mustHaveModel().addLiteral(this , p, o);
206:                return this ;
207:            }
208:
209:            public Resource addLiteral(Property p, double o) {
210:                Model m = mustHaveModel();
211:                m.add(this , p, m.createTypedLiteral(o));
212:                return this ;
213:            }
214:
215:            public Resource addLiteral(Property p, float o) {
216:                Model m = mustHaveModel();
217:                m.add(this , p, m.createTypedLiteral(o));
218:                return this ;
219:            }
220:
221:            public Resource addProperty(Property p, String o) {
222:                mustHaveModel().add(this , p, o);
223:                return this ;
224:            }
225:
226:            public Resource addProperty(Property p, String o, String l) {
227:                mustHaveModel().add(this , p, o, l);
228:                return this ;
229:            }
230:
231:            public Resource addProperty(Property p, String lexicalForm,
232:                    RDFDatatype datatype) {
233:                mustHaveModel().add(this , p, lexicalForm, datatype);
234:                return this ;
235:            }
236:
237:            /**
238:             * @deprecated Use {@link #addLiteral(Property,Object)} instead
239:             */
240:            public Resource addTypedProperty(Property p, Object o) {
241:                return addLiteral(p, o);
242:            }
243:
244:            public Resource addLiteral(Property p, Object o) {
245:                ModelCom m = mustHaveModel();
246:                m.add(this , p, m.createTypedLiteral(o));
247:                return this ;
248:            }
249:
250:            public Resource addProperty(Property p, RDFNode o) {
251:                mustHaveModel().add(this , p, o);
252:                return this ;
253:            }
254:
255:            public boolean hasProperty(Property p) {
256:                return mustHaveModel().contains(this , p);
257:            }
258:
259:            /**
260:             * @deprecated Use {@link #hasLiteral(Property,boolean)} instead
261:             */
262:            public boolean hasTypedProperty(Property p, boolean o) {
263:                return hasLiteral(p, o);
264:            }
265:
266:            public boolean hasLiteral(Property p, boolean o) {
267:                ModelCom m = mustHaveModel();
268:                return m.contains(this , p, m.createTypedLiteral(o));
269:            }
270:
271:            public boolean hasLiteral(Property p, long o) {
272:                ModelCom m = mustHaveModel();
273:                return m.contains(this , p, m.createTypedLiteral(o));
274:            }
275:
276:            public boolean hasLiteral(Property p, char o) {
277:                ModelCom m = mustHaveModel();
278:                return m.contains(this , p, m.createTypedLiteral(o));
279:            }
280:
281:            public boolean hasLiteral(Property p, double o) {
282:                ModelCom m = mustHaveModel();
283:                return m.contains(this , p, m.createTypedLiteral(o));
284:            }
285:
286:            public boolean hasLiteral(Property p, float o) {
287:                ModelCom m = mustHaveModel();
288:                return m.contains(this , p, m.createTypedLiteral(o));
289:            }
290:
291:            public boolean hasProperty(Property p, String o) {
292:                return mustHaveModel().contains(this , p, o);
293:            }
294:
295:            public boolean hasProperty(Property p, String o, String l) {
296:                return mustHaveModel().contains(this , p, o, l);
297:            }
298:
299:            public boolean hasLiteral(Property p, Object o) {
300:                ModelCom m = mustHaveModel();
301:                return m.contains(this , p, m.createTypedLiteral(o));
302:            }
303:
304:            public boolean hasProperty(Property p, RDFNode o) {
305:                return mustHaveModel().contains(this , p, o);
306:            }
307:
308:            public Resource removeProperties() {
309:                removeAll(null);
310:                return this ;
311:            }
312:
313:            public Resource removeAll(Property p) {
314:                mustHaveModel().removeAll(this , p, (RDFNode) null);
315:                return this ;
316:            }
317:
318:            public Resource begin() {
319:                mustHaveModel().begin();
320:                return this ;
321:            }
322:
323:            public Resource abort() {
324:                mustHaveModel().abort();
325:                return this ;
326:            }
327:
328:            public Resource commit() {
329:                mustHaveModel().commit();
330:                return this ;
331:            }
332:
333:            public Model getModel() {
334:                return (Model) getGraph();
335:            }
336:
337:            protected ModelCom getModelCom() {
338:                return (ModelCom) getGraph();
339:            }
340:        }
341:        /*
342:         *  (c) Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
343:         *  All rights reserved.
344:         *
345:         * Redistribution and use in source and binary forms, with or without
346:         * modification, are permitted provided that the following conditions
347:         * are met:
348:         * 1. Redistributions of source code must retain the above copyright
349:         *    notice, this list of conditions and the following disclaimer.
350:         * 2. Redistributions in binary form must reproduce the above copyright
351:         *    notice, this list of conditions and the following disclaimer in the
352:         *    documentation and/or other materials provided with the distribution.
353:         * 3. The name of the author may not be used to endorse or promote products
354:         *    derived from this software without specific prior written permission.
355:
356:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
357:         * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
358:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
359:         * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
360:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
361:         * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
362:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
363:         * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
364:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
365:         * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
366:         *
367:         * ResourceImpl.java
368:         *
369:         * Created on 03 August 2000, 13:45
370:         */
w__w_w._j___a__v_a2s___.__c__om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.