|
18 | 18 | package org.apache.commons.io.build; |
19 | 19 |
|
20 | 20 | import java.io.ByteArrayInputStream; |
| 21 | +import java.io.Closeable; |
21 | 22 | import java.io.File; |
22 | 23 | import java.io.FileInputStream; |
23 | 24 | import java.io.FileNotFoundException; |
|
67 | 68 | * expose only the operations that make sense for the underlying source or sink; invoking an unsupported operation |
68 | 69 | * results in {@link UnsupportedOperationException} (see, for example, {@link #getFile()} and {@link #getPath()}). |
69 | 70 | * </p> |
70 | | - * |
| 71 | + * <p> |
| 72 | + * An instance doesn't own its origin, it holds on to it to allow conversions. There are two use cases related to resource management for a Builder: |
| 73 | + * </p> |
| 74 | + * <ul> |
| 75 | + * <li> |
| 76 | + * A client allocates a {@linkplain Closeable} (or {@linkplain AutoCloseable}) resource, creates a Builder, and gives the Builder that resource by calling a |
| 77 | + * setter method. No matter what happens next, the client is responsible for releasing the resource ({@code Closeable.close()}). In this case, the origin |
| 78 | + * wraps but doesn't own the closeable resource. There is no transfer of ownership. |
| 79 | + * </li> |
| 80 | + * <li> |
| 81 | + * A client creates a Builder and gives it a non-Closeable object, like a File or a Path. The client then calls the Builder's factory method |
| 82 | + * (like {@linkplain #get()}), and that call returns a Closeable or a resource that requires releasing in some other way. No matter what happens next, the |
| 83 | + * client is responsible for releasing that resource. In this case, the origin doesn't wrap a closeable resource. |
| 84 | + * </li> |
| 85 | + * </ul> |
| 86 | + * <p> |
| 87 | + * In both cases, the client causes the allocation and is responsible for releasing the resource. |
| 88 | + * </p> |
71 | 89 | * <p> |
72 | 90 | * The table below summarizes which views and conversions are supported for each origin type. |
73 | 91 | * Column headers show the target view; cells indicate whether that view is available from the origin in that row. |
|
0 commit comments