Source Code Cross Referenced for RDFClauseSet.java in  » Rule-Engine » Mandarax » org » mandarax » rdf » 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 » Rule Engine » Mandarax » org.mandarax.rdf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 1999-2004 <a href="mailto:mandarax@jbdietrich.com">Jens Dietrich</a>
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:
019:        package org.mandarax.rdf;
020:
021:        import java.net.MalformedURLException;
022:        import java.net.URL;
023:        import java.util.*;
024:        import org.apache.commons.collections.iterators.ArrayIterator;
025:        import org.mandarax.kernel.*;
026:        import org.mandarax.util.ClauseIterator;
027:
028:        /**
029:         * Clause set implementation to access RDF documents. 
030:         * <p>
031:         * A RDF document usually contains more than one predicate. However, the predicates must be known 
032:         * when adding the clause set to a knowledge base as the kb uses them for internal indexing (i.e. 
033:         * to support retrieval of knowledge for a certain predicate). There are two strategies how this can be achieved: 
034:         * <ol>
035:         * <li>Using the property <code>predicates</code>
036:         * <li>Gathering the predicates from the document. This is the default strategy, it happens when <code>getKey()</code>
037:         * is called (e.g., by the kb) and the predicates have not been initialized (lazy initialization). This can be customized
038:         * using the <code>maxFetchSize</code> property which constraints the max number of statements analyzed. 
039:         * <p>
040:         * TODO implement a strategy in the kb for clause sets to be used for arbitrary predicates.
041:         * <p>
042:         * The RDF is read from a URL. If the URL is a network URL (= not a local file), firewalls and proxies
043:         * must be configured correctly. Theer are various ways to accomplish this. 
044:         * E.g., one may include the following parameter on the java command line:
045:         * <p><code>-DsocksProxyHost=[your-proxy-domain-name-or-ip-address] </code> // for a socks proxy 
046:         * <br><code>-DproxySet=true -DproxyHost=[your-proxy] -DproxyPort=[your-proxy-port-number] </code> // for an http proxy
047:         * <p>
048:         * These properties can also be set programatically as follows:
049:         * <p><code>
050:         * <br>System.getProperties().put("proxySet","true");
051:         * <br>System.getProperties().put("proxyHost","proxy.hostname");
052:         * <br>System.getProperties().put("proxyPort",port_number);
053:         * </code> 
054:         * @author <A HREF="mailto:j.b.dietrich@massey.ac.nz">Jens Dietrich</A> <A HREF="mailto:paschke@in.tum.de">Adrian Paschke</A>
055:         * @version 1.1 <01 August 2004>
056:         * @since 0.1
057:         */
058:
059:        public class RDFClauseSet extends AbstractPropertiesSupport implements 
060:                ClauseSet, RDFLogger, RDFConstants {
061:
062:            private URL url = null;
063:            private String language = RDFXML;
064:            private Predicate[] predicates = null;
065:            int maxFetchSize = -1; // this means NO LIMIT
066:
067:            /**
068:             * Empty constructor.
069:             * The url should be passed. This constructor is included to make this a POJO (plain old java object) 
070:             * and to support tools based on reflection.
071:             */
072:            public RDFClauseSet() {
073:                super ();
074:            }
075:
076:            /**
077:             * Constructor.
078:             * @param url the RDF model is loaded from this URL
079:             */
080:            public RDFClauseSet(URL url) {
081:                super ();
082:                this .url = url;
083:            }
084:
085:            /**
086:             * Constructor.
087:             * @param f a local file
088:             * @exception a MalformedURLException is thrown if the file cannot be converted into a URL
089:             */
090:            public RDFClauseSet(java.io.File f) throws MalformedURLException {
091:                super ();
092:                this .url = f.toURL();
093:            }
094:
095:            /**
096:             * Add a clause set listener.
097:             * @param l the listener
098:             */
099:            public void addClauseSetChangeListener(ClauseSetChangeListener l) {
100:                // TODO
101:            }
102:
103:            /**
104:             * Get a key for indexing. The knowledge base is supposed to
105:             * contain only clauses having the same key object. 
106:             * @return array of RDFPredicate
107:             */
108:            public synchronized Object getKey() {
109:                return predicates;
110:            }
111:
112:            /**
113:             * Remove a clause set listener.
114:             * @param l the listener
115:             */
116:            public void removeClauseSetChangeListener(ClauseSetChangeListener l) {
117:                // TODO
118:            }
119:
120:            /**
121:             * Get an iterator iterating over the predicates contained in this clause set.
122:             * @return an iterator
123:             */
124:            public Iterator predicates() {
125:                return new ArrayIterator(predicates);
126:            }
127:
128:            /**
129:             * Return a clause iterator.
130:             * @return a clause iterator
131:             */
132:            public ClauseIterator clauses() throws ClauseSetException {
133:                return new RDFClauseIterator(url, language, null);
134:            }
135:
136:            /**
137:             * Return a clause iterator.
138:             * @return a clause iterator
139:             * @param query the query clause
140:             * @param additionalParameter an optional additional parameter
141:             * @see org.mandarax.kernel.KnowledgeOwner#clauses(org.mandarax.kernel.Clause, java.lang.Object)
142:             */
143:            public ClauseIterator clauses(Clause query,
144:                    Object additionalParameter) throws ClauseSetException {
145:                Object obj = query.getKey();
146:                if (obj == null || !(obj instanceof  RDFPredicate))
147:                    throw new ClauseSetException(
148:                            "Cannot get clause iterator, rdf predicate expected instead of "
149:                                    + obj);
150:                return new RDFClauseIterator(url, language, (RDFPredicate) obj);
151:            }
152:
153:            /**
154:             * Get the url.
155:             * @return the url
156:             */
157:            public URL getURL() {
158:                return url;
159:            }
160:
161:            /**
162:             * Set the url.
163:             * @param url the url
164:             */
165:            public void setURL(URL url) {
166:                this .url = url;
167:            }
168:
169:            /**
170:             * Convert this object to a string.
171:             * @return a string
172:             */
173:            public String toString() {
174:                return new StringBuffer().append("aRDFClauseSet(").append(
175:                        this .url).append(')').toString();
176:            }
177:
178:            /**
179:             * Get the max fetch size.
180:             * @return Returns the maxFetchSize.
181:             */
182:            public int getMaxFetchSize() {
183:                return maxFetchSize;
184:            }
185:
186:            /**
187:             * Set the max fetch size.
188:             * @param maxFetchSize The maxFetchSize to set.
189:             */
190:            public void setMaxFetchSize(int maxFetchSize) {
191:                this .maxFetchSize = maxFetchSize;
192:            }
193:
194:            /**
195:             * Get the predicates.
196:             * @return Returns the predicates.
197:             */
198:            public Predicate[] getPredicates() {
199:                return predicates;
200:            }
201:
202:            /**
203:             * Set the predicates.
204:             * @param predicates The predicates to set.
205:             */
206:            public void setPredicates(Predicate[] predicates) {
207:                this.predicates = predicates;
208:            }
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.