Package org.apache.solr.common.util

# Class ContentStreamBase

java.lang.Object
org.apache.solr.common.util.ContentStreamBase

All Implemented Interfaces:
  `ContentStream`

Direct Known Subclasses:
  `ContentStreamBase.ByteArrayStream`, `ContentStreamBase.FileStream`, `ContentStreamBase.StringStream`, `ContentStreamBase.URLStream`

public abstract class ContentStreamBase extends Object implements ContentStream
Three concrete implementations for ContentStream - one for File/URL/String

Since:
  solr 1.2

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`ContentStreamBase.ByteArrayStream`
Construct a `ContentStream` from a `File`
`static class`
`ContentStreamBase.FileStream`
Construct a `ContentStream` from a `File`
`static class`
`ContentStreamBase.StringStream`
Construct a `ContentStream` from a `String`
`static class`
`ContentStreamBase.URLStream`
Construct a `ContentStream` from a `URL` This uses a `URLConnection` to get the content stream

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`APPLICATION_GZIP`
`static final String`
`APPLICATION_JSON`
`static final String`
`APPLICATION_OCTET_STREAM`
`static final String`
`APPLICATION_XML`
`protected String`
`contentType`
`static final String`
`DEFAULT_CHARSET`
`protected String`
`name`
`protected Long`
`size`
`protected String`
`sourceInfo`
`static final String`
`TEXT_XML`

## Constructor Summary

Constructors
Constructor
Description
`ContentStreamBase()`

## Method Summary

Modifier and Type
Method
Description
`protected String`
`attemptToDetermineContentType()`
`static ContentStream`
`create(RequestWriter requestWriter, SolrRequest req)`
`static String`
`getCharsetFromContentType(String contentType)`
`String`
`getContentType()`
`String`
`getName()`
`Reader`
`getReader()`
Base reader implementation.
`Long`
`getSize()`
`String`
`getSourceInfo()`
`void`
`setContentType(String contentType)`
`void`
`setName(String name)`
`void`
`setSize(Long size)`
`void`
`setSourceInfo(String sourceInfo)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.solr.common.util.ContentStream

`getStream`

## Field Details

### DEFAULT_CHARSET

public static final String DEFAULT_CHARSET

### TEXT_XML

public static final String TEXT_XML

See Also:
  - Constant Field Values

### APPLICATION_OCTET_STREAM

public static final String APPLICATION_OCTET_STREAM

See Also:
  - Constant Field Values

### APPLICATION_GZIP

public static final String APPLICATION_GZIP

See Also:
  - Constant Field Values

### APPLICATION_XML

public static final String APPLICATION_XML

See Also:
  - Constant Field Values

### APPLICATION_JSON

public static final String APPLICATION_JSON

See Also:
  - Constant Field Values

### name

protected String name

### sourceInfo

protected String sourceInfo

### contentType

protected String contentType

### size

protected Long size

## Constructor Details

### ContentStreamBase

public ContentStreamBase()

## Method Details

### getCharsetFromContentType

public static String getCharsetFromContentType(String contentType)

### attemptToDetermineContentType

protected String attemptToDetermineContentType()

### getReader

public Reader getReader() throws IOException
Base reader implementation. If the contentType declares a charset use it, otherwise use "utf-8".

Specified by:
  `getReader` in interface `ContentStream`
Throws:
  `IOException`

### getContentType

public String getContentType()

Specified by:
  `getContentType` in interface `ContentStream`

### setContentType

public void setContentType(String contentType)

### getName

public String getName()

Specified by:
  `getName` in interface `ContentStream`

### setName

public void setName(String name)

### getSize

public Long getSize()

Specified by:
  `getSize` in interface `ContentStream`
Returns:
  the stream size or `null` if not known

### setSize

public void setSize(Long size)

### getSourceInfo

public String getSourceInfo()

Specified by:
  `getSourceInfo` in interface `ContentStream`

### setSourceInfo

public void setSourceInfo(String sourceInfo)

### create

public static ContentStream create(RequestWriter requestWriter, SolrRequest req) throws IOException

Throws:
  `IOException`