Package aQute.bnd.service.url
Class TaggedData
- java.lang.Object
-
- aQute.bnd.service.url.TaggedData
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class TaggedData extends java.lang.Object implements java.io.Closeable
Represents a data stream that has a tag associated with it; the primary use-case is an HTTP response stream with an ETag header.
-
-
Field Summary
Fields Modifier and Type Field Description private java.net.URLConnection
con
private static java.util.regex.Pattern
ENTITIES_P
private java.lang.String
etag
private java.io.File
file
private static java.util.regex.Pattern
HTML_TAGS_P
private java.io.InputStream
in
private java.lang.String
message
private static java.util.regex.Pattern
NEWLINES_P
private int
responseCode
private java.net.URI
url
-
Constructor Summary
Constructors Constructor Description TaggedData(java.lang.String tag, java.io.InputStream inputStream)
Deprecated.TaggedData(java.lang.String tag, java.io.InputStream inputStream, int responseCode)
Deprecated.TaggedData(java.lang.String tag, java.io.InputStream inputStream, int responseCode, long modified, java.net.URI url)
Deprecated.TaggedData(java.net.URI url, int responseCode, java.io.File file)
TaggedData(java.net.URLConnection con, java.io.InputStream in)
TaggedData(java.net.URLConnection con, java.io.InputStream in, java.io.File file)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.String
cleanHtml(java.lang.CharSequence sb)
void
close()
private java.lang.String
entity(java.lang.String name)
java.net.URLConnection
getConnection()
java.io.File
getFile()
java.io.InputStream
getInputStream()
Returns the input stream containing the resource data.private java.lang.String
getMessage(java.net.URLConnection con)
long
getModified()
int
getResponseCode()
State
getState()
java.lang.String
getTag()
Returns the ETag for the retrieved resource, ornull
if the ETag was not provided by the server.java.net.URI
getUrl()
boolean
hasPayload()
boolean
isNotFound()
boolean
isNotModified()
boolean
isOk()
void
throwIt()
java.lang.String
toString()
-
-
-
Field Detail
-
con
private final java.net.URLConnection con
-
responseCode
private final int responseCode
-
etag
private final java.lang.String etag
-
in
private final java.io.InputStream in
-
url
private final java.net.URI url
-
file
private final java.io.File file
-
message
private final java.lang.String message
-
HTML_TAGS_P
private static final java.util.regex.Pattern HTML_TAGS_P
-
NEWLINES_P
private static final java.util.regex.Pattern NEWLINES_P
-
ENTITIES_P
private static final java.util.regex.Pattern ENTITIES_P
-
-
Constructor Detail
-
TaggedData
@Deprecated public TaggedData(java.lang.String tag, java.io.InputStream inputStream, int responseCode, long modified, java.net.URI url)
Deprecated.
-
TaggedData
@Deprecated public TaggedData(java.lang.String tag, java.io.InputStream inputStream, int responseCode)
Deprecated.
-
TaggedData
@Deprecated public TaggedData(java.lang.String tag, java.io.InputStream inputStream)
Deprecated.
-
TaggedData
public TaggedData(java.net.URLConnection con, java.io.InputStream in) throws java.lang.Exception
- Throws:
java.lang.Exception
-
TaggedData
public TaggedData(java.net.URLConnection con, java.io.InputStream in, java.io.File file) throws java.lang.Exception
- Throws:
java.lang.Exception
-
TaggedData
public TaggedData(java.net.URI url, int responseCode, java.io.File file) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-
Method Detail
-
getMessage
private java.lang.String getMessage(java.net.URLConnection con)
-
cleanHtml
private java.lang.String cleanHtml(java.lang.CharSequence sb)
-
entity
private java.lang.String entity(java.lang.String name)
-
getTag
public java.lang.String getTag()
Returns the ETag for the retrieved resource, ornull
if the ETag was not provided by the server.
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException
Returns the input stream containing the resource data.- Throws:
java.io.IOException
-
getResponseCode
public int getResponseCode()
-
getModified
public long getModified()
-
hasPayload
public boolean hasPayload() throws java.io.IOException
- Throws:
java.io.IOException
-
getUrl
public java.net.URI getUrl()
-
getConnection
public java.net.URLConnection getConnection()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isOk
public boolean isOk()
-
isNotModified
public boolean isNotModified()
-
throwIt
public void throwIt()
-
getState
public State getState()
-
isNotFound
public boolean isNotFound()
-
getFile
public java.io.File getFile()
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-