KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > retriever > ResourceRetriever


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * ResourceRetriever.java
22  *
23  * Created on January 9, 2006, 2:44 PM
24  *
25  * To change this template, choose Tools | Template Manager
26  * and open the template in the editor.
27  */

28
29 package org.netbeans.modules.xml.retriever;
30
31 import java.io.IOException JavaDoc;
32 import java.io.InputStream JavaDoc;
33 import java.net.URISyntaxException JavaDoc;
34 import java.util.HashMap JavaDoc;
35
36 /**
37  *
38  * @author girix
39  */

40 public interface ResourceRetriever {
41     /**
42      * This method will be called by the factory class. Impl should decide if it supports the protocol
43      * @param baseAddr originating documents address
44      * @param currentAddr address of the document that needs to be fetched - as mentioned in the base document.
45      * @return if impl supports then true else false
46      */

47     public boolean accept(String JavaDoc baseAddr, String JavaDoc currentAddr) throws URISyntaxException JavaDoc;
48     
49     /**
50      * Given the base doc address and the current address (that could be either relative or absoulte), determine the final address to fetch doc and get the stream of that doc.
51      * @param baseAddress address of the base document where the link was found
52      * @param documentAddress current document address as mentioned in the base doc
53      * @return Hash map has the "key" as the final address from where the file was fetched and "value" has the input sream of the file.
54      */

55     public HashMap JavaDoc<String JavaDoc,InputStream JavaDoc> retrieveDocument(
56             String JavaDoc baseAddress, String JavaDoc documentAddress) throws IOException JavaDoc,URISyntaxException JavaDoc;
57     
58     
59      /**
60      * Given the base doc address and the current address (that could be either relative or absoulte), determine the final address to fetch doc and get the stream of that doc.
61      * @param baseAddress address of the base document where the link was found
62      * @param documentAddress current document address as mentioned in the base doc
63      * @return Hash map has the "key" as the final address from where the file was fetched and "value" has the input sream of the file.
64      */

65     public String JavaDoc getEffectiveAddress(
66             String JavaDoc baseAddress, String JavaDoc documentAddress) throws IOException JavaDoc,URISyntaxException JavaDoc;
67     
68     
69     /**
70      * Must be called after retrieveDocument() method.
71      * This returns the number of chars in the stream.
72      * Useful for URL retriever where its better to know the length upfront.
73      */

74     public long getStreamLength();
75 }
76
Popular Tags