# ContentHandler

public abstract class **ContentHandler** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
The abstract class `ContentHandler` is the superclass
of all classes that read an `Object` from a
`URLConnection`.


An application does not generally call the
`getContent` method in this class directly. Instead, an
application calls the `getContent` method in class
`URL` or in `URLConnection`.
The application's content handler factory (an instance of a class that
implements the interface `ContentHandlerFactory` set
up by a call to `setContentHandler`) is
called with a `String` giving the MIME type of the
object being received on the socket. The factory returns an
instance of a subclass of `ContentHandler`, and its
`getContent` method is called to create the object.


If no content handler could be found, URLConnection will
look for a content handler in a user-defineable set of places.
By default it looks in sun.net.www.content, but users can define a
vertical-bar delimited set of class prefixes to search through in
addition by defining the java.content.handler.pkgs property.
The class name must be of the form:

```
     {package-prefix}.{major}.{minor}
 e.g.
     YoyoDyne.experimental.text.plain
 
```
If the loading of the content handler class would be performed by a classloader that is outside of the delegation chain of the caller, the JVM will need the RuntimePermission "getClassLoader".

<br />

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ContentHandler.html#getContent(java.net.URLConnection)`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ContentHandlerFactory.html`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URL.html#getContent()`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URLConnection.html`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URLConnection.html#getContent()`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URLConnection.html#setContentHandlerFactory(java.net.ContentHandlerFactory)`

### Public Constructor Summary

|---|---|
|   | [ContentHandler](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ContentHandler.html#ContentHandler())() |

### Public Method Summary

|---|---|
| abstract [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [getContent](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ContentHandler.html#getContent(java.net.URLConnection))([URLConnection](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URLConnection.html) urlc) Given a URL connect stream positioned at the beginning of the representation of an object, this method reads that stream and creates an object from it. |
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [getContent](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ContentHandler.html#getContent(java.net.URLConnection,%20java.lang.Class[]))([URLConnection](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URLConnection.html) urlc, [Class\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html) classes) Given a URL connect stream positioned at the beginning of the representation of an object, this method reads that stream and creates an object that matches one of the types specified. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Public Constructors

#### public
**ContentHandler**
()

<br />

## Public Methods

#### public abstract [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)
**getContent**
([URLConnection](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URLConnection.html) urlc)

Given a URL connect stream positioned at the beginning of the
representation of an object, this method reads that stream and
creates an object from it.

##### Parameters

| urlc | a URL connection. |
|---|---|

##### Returns

- the object read by the `ContentHandler`.

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error occurs while reading the object. |
|---|---|

#### public [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)
**getContent**
([URLConnection](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URLConnection.html) urlc, [Class\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html) classes)

Given a URL connect stream positioned at the beginning of the
representation of an object, this method reads that stream and
creates an object that matches one of the types specified.

The default implementation of this method should call getContent()
and screen the return type for a match of the suggested types.

##### Parameters

| urlc | a URL connection. |
| classes | an array of types requested |
|---|---|

##### Returns

- the object read by the `ContentHandler` that is the first match of the suggested types. null if none of the requested are supported.

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error occurs while reading the object. |
|---|---|