KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > jcr > impl > core > query > QueryManagerImpl


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5
6 package org.exoplatform.services.jcr.impl.core.query;
7
8 import javax.jcr.query.QueryManager;
9 import javax.jcr.query.Query;
10 import javax.jcr.query.InvalidQueryException;
11 import java.util.HashMap JavaDoc;
12
13
14 import javax.jcr.RepositoryException;
15 import org.exoplatform.services.jcr.impl.core.NodeImpl;
16 import org.exoplatform.services.jcr.impl.core.WorkspaceImpl;
17
18 /**
19  * Created by The eXo Platform SARL .
20  *
21  * @author <a HREF="mailto:geaz@users.sourceforge.net">Gennady Azarenkov</a>
22  * @version $Id: QueryManagerImpl.java,v 1.3 2004/07/08 23:36:48 benjmestrallet Exp $
23  */

24
25 public class QueryManagerImpl implements QueryManager {
26
27   private static QueryManagerImpl instance;
28   private HashMap JavaDoc languages;
29   private WorkspaceImpl workspace;
30
31   private QueryManagerImpl() {
32     languages = new HashMap JavaDoc();
33     languages.put("JCRQL-SSES", "JCR query language");
34 // new QueryLanguageDef(new org.exoplatform.services.jcr.impl.core.query.jcrql.token.Select()));
35
}
36
37   public static QueryManagerImpl getInstance() {
38     if (instance == null)
39       instance = new QueryManagerImpl();
40     return instance;
41   }
42
43   public void init(WorkspaceImpl workspace) {
44     this.workspace = workspace;
45   }
46
47   /**
48    * 6.9.1
49    * Creates a transient Query.
50    */

51   public Query createQuery(String JavaDoc statement, int language) throws InvalidQueryException, RepositoryException {
52     if (workspace == null)
53       throw new RepositoryException("Query Manager is not initialized!");
54
55 // return new QueryImpl(workspace, null);
56

57     return null;
58   }
59
60   /**
61    * 6.9.1
62    * Retrieves an existing persistent query. If absPath is not the
63    * path of a persisted query (i.e., if it does not point to a node of
64    * node type nt:query) then an InvalidPathException is
65    * thrown. If the query exists but is invalid, an
66    * InvalidQueryException is thrown.
67    */

68   public Query getQuery(String JavaDoc absPath) throws InvalidQueryException, RepositoryException {
69 /*
70         if(workspace == null)
71             throw new RepositoryException("Query Manager is not initialized!");
72
73         NodeImpl node = workspace.getNodeByPath(absPath);
74         if(node == null)
75             throw new RepositoryException("Node not found at <"+absPath+"> !");
76
77 // return new QueryImpl(node);
78
79         return null;
80 */

81     throw new RepositoryException("Not implemented yet !");
82
83   }
84
85   /**
86    * 6.9.1
87    * Returns a string identifier for each supported query language.
88    * The string should consist of two parts. The first identifying the
89    * main query language, the second identifying the full-text
90    * search language embedded in the SEARCH clause.
91    */

92   public int[] getSupportedQueryLanguages() {
93 // return (String[])languages.keySet().toArray();
94

95     int[] langs = new int[1];
96     langs[1] = 0;
97     return langs;
98   }
99 /*
100     public Token getFirstExpectedToken(String language) throws UnsupportedQueryLanguageException {
101         QueryLanguageDef lang = (QueryLanguageDef)languages.get(language);
102         if(lang == null)
103             throw new UnsupportedQueryLanguageException("Language <"+language+"> is not supported!");
104         return lang.getFirstExpectedToken();
105     }
106
107     public class QueryLanguageDef {
108         private Token firstExpectedToken;
109         public QueryLanguageDef(Token firstExpectedToken) {
110             this.firstExpectedToken = firstExpectedToken;
111         }
112
113         public Token getFirstExpectedToken() {
114             return firstExpectedToken;
115         }
116     }
117 */

118 }
119
Popular Tags