KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > catalog > lib > URLEnvironment


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 package org.netbeans.modules.xml.catalog.lib;
20
21 import java.io.*;
22 import java.net.*;
23 import java.util.*;
24
25 import org.openide.text.*;
26 import org.openide.ErrorManager;
27
28
29 /**
30  * Defines numb read-only URL environment but finding CloneableOpenSupport (outerclass).
31  * It hardcodes <code>text/xml</code> MIME type.
32  *
33  * @author Petr Kuzel
34  * @version
35  */

36 public abstract class URLEnvironment implements CloneableEditorSupport.Env {
37
38     /** Serial Version UID */
39     private static final long serialVersionUID =9098933339895727443L;
40
41     private final URL peer;
42     
43     private transient Date modified;
44         
45     /** Creates new StreamEnvironment */
46     public URLEnvironment(URL url) {
47         if (url == null) throw new NullPointerException JavaDoc();
48         peer = url;
49         modified = new Date();
50     }
51         
52     public void markModified() throws java.io.IOException JavaDoc {
53         throw new IOException("r/o"); // NOI18N
54
}
55     
56     public void unmarkModified() {
57     }
58
59     public void removePropertyChangeListener(java.beans.PropertyChangeListener JavaDoc propertyChangeListener) {
60     }
61     
62     public boolean isModified() {
63         return false;
64     }
65     
66     public java.util.Date JavaDoc getTime() {
67         return modified;
68     }
69     
70     public void removeVetoableChangeListener(java.beans.VetoableChangeListener JavaDoc vetoableChangeListener) {
71     }
72     
73     public boolean isValid() {
74         return true;
75     }
76     
77     public java.io.OutputStream JavaDoc outputStream() throws java.io.IOException JavaDoc {
78         throw new IOException("r/o"); // NOI18N
79
}
80
81     /**
82      * @return "text/xml"
83      */

84     public java.lang.String JavaDoc getMimeType() {
85         return "text/xml"; // NOI18N
86
}
87
88     /**
89      * Always return fresh stream.
90      */

91     public java.io.InputStream JavaDoc inputStream() throws java.io.IOException JavaDoc {
92         try {
93             return peer.openStream();
94         } catch (IOException ex) {
95             // #21556
96
// annotate exception as USER error, he provided wrong URL
97
ErrorManager err = ErrorManager.getDefault();
98             err.annotate(ex, ErrorManager.USER, null, null, null, null);
99             throw ex;
100         }
101     }
102     
103     public void addVetoableChangeListener(java.beans.VetoableChangeListener JavaDoc vetoableChangeListener) {
104     }
105     
106     public void addPropertyChangeListener(java.beans.PropertyChangeListener JavaDoc propertyChangeListener) {
107     }
108             
109 }
110
Popular Tags