01: package com.jclark.xml.parse;
02:
03: import java.io.InputStream;
04: import java.net.URL;
05:
06: /**
07: * Information about an open external entity.
08: * This is used to by <code>EntityManager</code> to return
09: * information about an external entity that is has opened.
10: * @see EntityManager
11: * @version $Revision: 1.4 $ $Date: 1998/02/17 04:20:47 $
12: */
13: public class OpenEntity {
14: private InputStream inputStream;
15: private String encoding;
16: private URL base;
17: private String location;
18:
19: /**
20: * Creates and initializes an <code>OpenEntity</code> which uses
21: * an externally specified encoding.
22: */
23: public OpenEntity(InputStream inputStream, String location,
24: URL base, String encoding) {
25: this .inputStream = inputStream;
26: this .location = location;
27: this .base = base;
28: this .encoding = encoding;
29: }
30:
31: /**
32: * Creates and initializes an <code>OpenEntity</code> which uses
33: * the encoding specified in the entity.
34: */
35: public OpenEntity(InputStream inputStream, String location, URL base) {
36: this (inputStream, location, base, null);
37: }
38:
39: /**
40: * Returns an InputStream containing the entity's bytes.
41: * If this is called more than once on the same
42: * OpenEntity, it will return the same InputStream.
43: */
44: public final InputStream getInputStream() {
45: return inputStream;
46: }
47:
48: /**
49: * Returns the name of the encoding to be used to convert the entity's
50: * bytes into characters, or null if this should be determined from
51: * the entity itself using XML's rules.
52: */
53: public final String getEncoding() {
54: return encoding;
55: }
56:
57: /**
58: * Returns the URL to use as the base URL for resolving relative URLs
59: * contained in the entity.
60: */
61: public final URL getBase() {
62: return base;
63: }
64:
65: /**
66: * Returns a string representation of the location of the entity
67: * suitable for use in error messages.
68: */
69: public final String getLocation() {
70: return location;
71: }
72:
73: }
|