KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > retriever > catalog > ProjectCatalogSupport


1 /*
2  * ProjectCatalogSupport.java
3  *
4  * Created on December 15, 2006, 4:23 PM
5  *
6  * To change this template, choose Tools | Template Manager
7  * and open the template in the editor.
8  */

9
10 package org.netbeans.modules.xml.retriever.catalog;
11
12 import java.io.IOException JavaDoc;
13 import java.net.URI JavaDoc;
14 import java.net.URISyntaxException JavaDoc;
15 import org.netbeans.modules.xml.xam.locator.CatalogModelException;
16 import org.openide.filesystems.FileObject;
17
18 /**
19  * Extend this class to implement custom URIs that could be added and resolved by the project CatalogModel(s).
20  * The project catalog resolver (org.netbeans.modules.xml.retriever.catalog.CatalogModel
21  * and org.netbeans.modules.xml.retriever.catalog.CatalogWriteModel) will look for
22  * this implementation in the Project.lookup(). When present any URI that is not understood by the
23  * resolver will be deligated to the impl of this class.
24  *
25  * One of the usecase of this class is when a special URI has to be written in to the
26  * catalog file by a project that is referencing artifacts from another dependent sub-project.
27  *
28  * @author girix
29  */

30 public abstract class ProjectCatalogSupport {
31     
32     /** Creates a new instance of ProjectCatalogSupport */
33     public ProjectCatalogSupport() {
34     }
35     
36     /**
37      * This method will be called by the CatalogWriteModel if the FileObject passed
38      * in the org.netbeans.modules.xml.retriever.catalog.addURI(URI LEFT, FileObject rightFO);
39      * does not belong to same project as of the catalog. The impl of this class must
40      * return a URI similar to the following:
41      * sample URI = nb-uri:project.project_identifier_name/src/a/b/c/xyz.xsd
42      *
43      * @param foTobeAddedInCat FileObject that is supposed to be added to the catalog file of the project
44      * @return URI constructed for the passed FO. A URI could look something like this: nb-uri:project.project_identifier_name/src/a/b/c/xyz.xsd
45      */

46     public abstract URI JavaDoc constructProjectProtocol(FileObject foTobeAddedInCat);
47     
48     
49     /**
50      * This method is called when the CatalogModel looks in to the catalog file and
51      * gets back a URI that is not a standard URI. If the parameter URI is
52      * understood by the impl of this class, return true, else false.
53      *
54      * This method is for extension purpose. If a project wants to add a new sort of
55      * URI in to the catalog file in the future, it will have to implement this method.
56      *
57      * @param uriStoredInCatFile URI found in the catalog file.
58      * @return True if this URI is understood by this impl. False otherwise.
59      */

60     
61     public abstract boolean isProjectProtocol(URI JavaDoc uriStoredInCatFile);
62     
63     
64     
65     /**
66      * This method will be called after isProjectProtocol(URI) returns true.
67      * The impl has to interpret the URI parameter (that looks similar to sample
68      * URI mentioned above) and get the equivalent FileObject associated with that
69      * URI. A null should be returned in case if the file is not found on
70      * disk (and hence can not create corresponding FileObject)
71      *
72      * @param uriToBeResolved URI that is to be interpreted by the impl.
73      * @return FileObject associated with the URI.
74      */

75     public abstract FileObject resolveProjectProtocol(URI JavaDoc uriToBeResolved);
76     
77     
78     
79     /**
80      * This method should add catalog entry in to the project catalog given
81      * 2 file objects. The impl muse calculate the key and value pair for the
82      * catalog entry and call CatalogWriteModel for adding the entry. The URI
83      * returned must be the calculated key of the catalog entry.
84      * @param source The FileObject that is making this entry to the catalog. This arg may be
85      * used for calculating the Key of the catalog entry.
86      * @param target The FileObject that is referenced by this indirection via catalog entry.
87      * @return The key (Left Hand Side) of the catalog entry that was added new in to the catalog file. If nothing was added then null.
88      */

89     public abstract URI JavaDoc createCatalogEntry(FileObject source, FileObject target) throws
90             CatalogModelException, IOException JavaDoc ;
91     
92     /**
93      * This method should implement the implementation logic for removing a catalog entry with the parameter URI as the key (LHS).
94      * The impl must verify if there entry is indeed present in the catalog and then do a delete.
95      * @return True if the delete was successful false otherwise.
96      * @param uri URI to be removed from the catalog.
97      */

98     public abstract boolean removeCatalogEntry(URI JavaDoc uri) throws IOException JavaDoc;
99     
100 }
101
Popular Tags