Source Code Cross Referenced for MemURI.java in  » RSS-RDF » sesame » org » openrdf » sail » memory » model » 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 » sesame » org.openrdf.sail.memory.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2006.
003:         *
004:         * Licensed under the Aduna BSD-style license.
005:         */
006:        package org.openrdf.sail.memory.model;
007:
008:        import org.openrdf.model.URI;
009:
010:        /**
011:         * A MemoryStore-specific implementation of URI that stores separated namespace
012:         * and local name information to enable reuse of namespace String objects
013:         * (reducing memory usage) and that gives it node properties.
014:         */
015:        public class MemURI implements  URI, MemResource {
016:
017:            /*-----------*
018:             * Variables *
019:             *-----------*/
020:
021:            /**
022:             * 
023:             */
024:            private static final long serialVersionUID = 9118488004995852467L;
025:
026:            /**
027:             * The URI's namespace.
028:             */
029:            private final String namespace;
030:
031:            /**
032:             * The URI's local name.
033:             */
034:            private final String localName;
035:
036:            /**
037:             * The object that created this MemURI.
038:             */
039:            transient private Object creator;
040:
041:            /**
042:             * The MemURI's hash code, 0 if not yet initialized.
043:             */
044:            private int hashCode = 0;
045:
046:            /**
047:             * The list of statements for which this MemURI is the subject.
048:             */
049:            transient private MemStatementList subjectStatements = null;
050:
051:            /**
052:             * The list of statements for which this MemURI is the predicate.
053:             */
054:            transient private MemStatementList predicateStatements = null;
055:
056:            /**
057:             * The list of statements for which this MemURI is the object.
058:             */
059:            transient private MemStatementList objectStatements = null;
060:
061:            /**
062:             * The list of statements for which this MemURI represents the context.
063:             */
064:            transient private MemStatementList contextStatements = null;
065:
066:            /*--------------*
067:             * Constructors *
068:             *--------------*/
069:
070:            /**
071:             * Creates a new MemURI for a URI.
072:             * 
073:             * @param creator
074:             *        The object that is creating this MemURI.
075:             * @param namespace
076:             *        namespace part of URI.
077:             * @param localName
078:             *        localname part of URI.
079:             */
080:            public MemURI(Object creator, String namespace, String localName) {
081:                this .creator = creator;
082:                this .namespace = namespace;
083:                this .localName = localName;
084:            }
085:
086:            /*---------*
087:             * Methods *
088:             *---------*/
089:
090:            // Overrides Object.toString(), implements URI.toString()
091:            @Override
092:            public String toString() {
093:                return namespace + localName;
094:            }
095:
096:            public String stringValue() {
097:                return toString();
098:            }
099:
100:            // Implements URI.getNamespace()
101:            public String getNamespace() {
102:                return namespace;
103:            }
104:
105:            // Implements URI.getLocalName()
106:            public String getLocalName() {
107:                return localName;
108:            }
109:
110:            // Overrides Object.equals(Object), implements URI.equals(Object)
111:            @Override
112:            public boolean equals(Object other) {
113:                if (this  == other) {
114:                    return true;
115:                }
116:
117:                if (other instanceof  MemURI) {
118:                    MemURI o = (MemURI) other;
119:                    return namespace.equals(o.getNamespace())
120:                            && localName.equals(o.getLocalName());
121:                } else if (other instanceof  URI) {
122:                    String otherStr = other.toString();
123:
124:                    return namespace.length() + localName.length() == otherStr
125:                            .length()
126:                            && otherStr.endsWith(localName)
127:                            && otherStr.startsWith(namespace);
128:                }
129:
130:                return false;
131:            }
132:
133:            // Overrides Object.hashCode(), implements URI.hashCode()
134:            @Override
135:            public int hashCode() {
136:                if (hashCode == 0) {
137:                    hashCode = toString().hashCode();
138:                }
139:
140:                return hashCode;
141:            }
142:
143:            // Implements MemValue.getCreator()
144:            public Object getCreator() {
145:                return creator;
146:            }
147:
148:            // Implements MemValue.getSubjectStatementList()
149:            public MemStatementList getSubjectStatementList() {
150:                if (subjectStatements == null) {
151:                    return EMPTY_LIST;
152:                } else {
153:                    return subjectStatements;
154:                }
155:            }
156:
157:            // Implements MemValue.getSubjectStatementCount()
158:            public int getSubjectStatementCount() {
159:                if (subjectStatements == null) {
160:                    return 0;
161:                } else {
162:                    return subjectStatements.size();
163:                }
164:            }
165:
166:            // Implements MemValue.addSubjectStatement(MemStatement)
167:            public void addSubjectStatement(MemStatement st) {
168:                if (subjectStatements == null) {
169:                    subjectStatements = new MemStatementList(4);
170:                }
171:
172:                subjectStatements.add(st);
173:            }
174:
175:            // Implements MemValue.removeSubjectStatement(MemStatement)
176:            public void removeSubjectStatement(MemStatement st) {
177:                subjectStatements.remove(st);
178:
179:                if (subjectStatements.isEmpty()) {
180:                    subjectStatements = null;
181:                }
182:            }
183:
184:            /**
185:             * Gets the list of statements for which this MemURI is the predicate.
186:             * 
187:             * @return a MemStatementList containing the statements.
188:             */
189:            public MemStatementList getPredicateStatementList() {
190:                if (predicateStatements == null) {
191:                    return EMPTY_LIST;
192:                } else {
193:                    return predicateStatements;
194:                }
195:            }
196:
197:            /**
198:             * Gets the number of Statements for which this MemURI is the predicate.
199:             * 
200:             * @return An integer larger than or equal to 0.
201:             */
202:            public int getPredicateStatementCount() {
203:                if (predicateStatements == null) {
204:                    return 0;
205:                } else {
206:                    return predicateStatements.size();
207:                }
208:            }
209:
210:            /**
211:             * Adds a statement to this MemURI's list of statements for which it is the
212:             * predicate.
213:             */
214:            public void addPredicateStatement(MemStatement st) {
215:                if (predicateStatements == null) {
216:                    predicateStatements = new MemStatementList(4);
217:                }
218:
219:                predicateStatements.add(st);
220:            }
221:
222:            /**
223:             * Removes a statement from this MemURI's list of statements for which it is
224:             * the predicate.
225:             */
226:            public void removePredicateStatement(MemStatement st) {
227:                predicateStatements.remove(st);
228:
229:                if (predicateStatements.isEmpty()) {
230:                    predicateStatements = null;
231:                }
232:            }
233:
234:            // Implements MemValue.getObjectStatementList()
235:            public MemStatementList getObjectStatementList() {
236:                if (objectStatements == null) {
237:                    return EMPTY_LIST;
238:                } else {
239:                    return objectStatements;
240:                }
241:            }
242:
243:            // Implements MemValue.getObjectStatementCount()
244:            public int getObjectStatementCount() {
245:                if (objectStatements == null) {
246:                    return 0;
247:                } else {
248:                    return objectStatements.size();
249:                }
250:            }
251:
252:            // Implements MemValue.addObjectStatement(MemStatement)
253:            public void addObjectStatement(MemStatement st) {
254:                if (objectStatements == null) {
255:                    objectStatements = new MemStatementList(4);
256:                }
257:                objectStatements.add(st);
258:            }
259:
260:            // Implements MemValue.removeObjectStatement(MemStatement)
261:            public void removeObjectStatement(MemStatement st) {
262:                objectStatements.remove(st);
263:                if (objectStatements.isEmpty()) {
264:                    objectStatements = null;
265:                }
266:            }
267:
268:            // Implements MemResource.getContextStatementList()
269:            public MemStatementList getContextStatementList() {
270:                if (contextStatements == null) {
271:                    return EMPTY_LIST;
272:                } else {
273:                    return contextStatements;
274:                }
275:            }
276:
277:            // Implements MemResource.getContextStatementCount()
278:            public int getContextStatementCount() {
279:                if (contextStatements == null) {
280:                    return 0;
281:                } else {
282:                    return contextStatements.size();
283:                }
284:            }
285:
286:            // Implements MemResource.addContextStatement(MemStatement)
287:            public void addContextStatement(MemStatement st) {
288:                if (contextStatements == null) {
289:                    contextStatements = new MemStatementList(4);
290:                }
291:
292:                contextStatements.add(st);
293:            }
294:
295:            // Implements MemResource.removeContextStatement(MemStatement)
296:            public void removeContextStatement(MemStatement st) {
297:                contextStatements.remove(st);
298:
299:                if (contextStatements.isEmpty()) {
300:                    contextStatements = null;
301:                }
302:            }
303:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.