KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > internal > core > NullContentReference


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.update.internal.core;
12
13 import java.io.File JavaDoc;
14 import java.io.IOException JavaDoc;
15 import java.io.InputStream JavaDoc;
16 import java.net.URL JavaDoc;
17
18 import org.eclipse.update.core.ContentReference;
19
20 /**
21  * NullContentReference implements a general access wrapper
22  * to feature and site content -- but, for which, there is no
23  * content actually found. This way, it can "keep" the ID that was
24  * requested, and still hold a place in lists and arrays, without a
25  * change to other program logic. It does, how ever require the internal
26  * algorithms to be more careful about assumptions made ... for example,
27  * just because asFile is null, it does not follow that asURL will not be null.
28  * <p>
29  * This class may not be instantiated or subclassed by clients.
30  * </p>
31  * @see org.eclipse.update.core.ContentReference
32  * @see org.eclipse.update.core.JarContentReference
33  * @see org.eclipse.update.core.JarEntryContentReference
34  */

35 public class NullContentReference extends ContentReference {
36
37
38     /**
39      * Contructor for the "missing jar" case.
40      *
41      * @param id
42      */

43     public NullContentReference(String JavaDoc id) {
44         super(id, (File JavaDoc) null);
45     }
46     /**
47      * A factory method to create a content reference of
48      * the same type.
49      *
50      * @param id "symbolic" path identifier
51      */

52     public ContentReference createContentReference(String JavaDoc id, File JavaDoc file) {
53         return new NullContentReference(id);
54     }
55
56     /**
57      * Overrides super class implementation to avoid throwing a FileNotFound exception.
58      *
59      * @return null
60      */

61     public InputStream JavaDoc getInputStream() throws IOException JavaDoc {
62         return null;
63     }
64     /**
65      * Overrides super class implementation to avoid throwing a FileNotFound exception.
66      *
67      * @return null
68      */

69     public File JavaDoc asFile() throws IOException JavaDoc {
70         return null;
71     }
72
73     /**
74      * Overrides super class implementation to avoid throwing URL exceptions.
75      *
76      * @return null
77      */

78     public URL JavaDoc asURL() throws IOException JavaDoc {
79         return null;
80     }
81
82     /**
83      * Return string representation of this reference.
84      *
85      * @return string representation
86      */

87     public String JavaDoc toString() {
88             return "Missing archive file: " + '(' + getIdentifier() + ')'; //$NON-NLS-1$
89
}
90 }
91
Popular Tags