Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.appengine.api.files.dev
Class FileMetadata

    java.lang.Object
      com.google.appengine.api.files.dev.FileMetadata

Direct Known Subclasses:
  BlobstoreFile, GSFile

    public abstract class FileMetadata

extends java.lang.Object

This class represents a single file stored by the local file service. This class is abstract. There are concrete subclasses corresponding to each of the concrete backend storage repositories.

Nested Class Summary
`static class` | `FileMetadata.LockState`
`static class` | `FileMetadata.OpenState` The state of a file in a particular session.

Field Summary
`protected java.lang.String` | `appendName` The name of the appendable version of this unfinalized file.
`protected ContentType` | `contentType`
`protected java.lang.String` | `currentSequenceKey` If this instance is for writing and it has not yet been finalized, then this variable stores the current sequence key
`protected boolean` | `finalized`
`protected java.lang.String` | `readName` The name of the readable version of this file once it is finalized.
`protected java.io.ByteArrayOutputStream` | `tempBytes` If this instance is for writing and it has not yet been finalized, then this variable stores the current bytes.

Constructor Summary
`FileMetadata(java.lang.String readName, java.lang.String appendName, ContentType contentType)`

Method Summary
`void` | `append(AppendRequest request)` Handle an append request
`protected static void` | `checkParameters(java.util.Map<java.lang.String,java.lang.String> parameters, java.lang.String... names)`
`protected static long` | `copy(java.io.InputStream from, java.io.OutputStream to, long maxBytes)` Copies `maxBytes` bytes from the input stream to the output stream.
`java.lang.String` | `getAppendName()`
`ContentType` | `getContentType()`
`protected abstract java.io.InputStream` | `getInputStream()`
`FileMetadata.LockState` | `getLockState(Session session)`
`FileMetadata.OpenState` | `getOpenState(Session session)`
`protected abstract java.io.OutputStream` | `getOutputStream()`
`boolean` | `isFinalized()`
`boolean` | `isOpenInDifferentSession(Session session)`
`void` | `lock(Session session)`
`static FileMetadata` | `newReadableInstance(LocalFileService localFileService, Clock clock, ParsedFileName parsedName)` Returns a new instance of `FileMetadata` if possible.
`ByteString` | `read(ReadRequest request)` Handle a Read request
`protected void` | `saveBlobInfo(com.google.appengine.api.datastore.DatastoreService datastore, com.google.appengine.api.blobstore.BlobKey blobKey, java.lang.String entityKind, java.lang.String mimeType, long currentTime, java.lang.String fileName, java.lang.String creationHandle)`
`void` | `setFinalized()`
`void` | `setState(FileMetadata.OpenState state, Session session)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### contentType

    protected ContentType contentType

### finalized

    protected boolean finalized

### readName

    protected final java.lang.String readName

  The name of the readable version of this file once it is finalized.

### appendName

    protected final java.lang.String appendName

  The name of the appendable version of this unfinalized file.

### currentSequenceKey

    protected java.lang.String currentSequenceKey

  If this instance is for writing and it has not yet been finalized, then this variable stores the current sequence key

### tempBytes

    protected final java.io.ByteArrayOutputStream tempBytes

  If this instance is for writing and it has not yet been finalized, then this variable stores the current bytes. These bytes will be copied to the remote file during finalization.

Constructor Detail

### FileMetadata

    public FileMetadata(java.lang.String readName,
                        java.lang.String appendName,
                        ContentType contentType)

Method Detail

### getAppendName

    public java.lang.String getAppendName()

### setFinalized

    public void setFinalized()

### isFinalized

    public boolean isFinalized()

### getContentType

    public ContentType getContentType()

### lock

    public void lock(Session session)

### getLockState

    public FileMetadata.LockState getLockState(Session session)

### setState

    public void setState(FileMetadata.OpenState state,
                         Session session)

### getOpenState

    public FileMetadata.OpenState getOpenState(Session session)

### isOpenInDifferentSession

    public boolean isOpenInDifferentSession(Session session)

### read

    public ByteString read(ReadRequest request)

  Handle a Read request

  Parameters:
    `request` - the request
  Returns:
    A `ByteString` containing the read bytes

### append

    public void append(AppendRequest request)

  Handle an append request

  Parameters:
    `request` - the request

### getInputStream

    protected abstract java.io.InputStream getInputStream()
                                                   throws java.io.IOException

  Throws:
    `java.io.IOException`

### getOutputStream

    protected abstract java.io.OutputStream getOutputStream()
                                                     throws java.io.IOException

  Throws:
    `java.io.IOException`

### checkParameters

    protected static void checkParameters(java.util.Map<java.lang.String,java.lang.String> parameters,
                                          java.lang.String... names)

### copy

    protected static long copy(java.io.InputStream from,
                               java.io.OutputStream to,
                               long maxBytes)
                        throws java.io.IOException

  Copies `maxBytes` bytes from the input stream to the output stream.

  Throws:
    `java.io.IOException`

### saveBlobInfo

    protected void saveBlobInfo(com.google.appengine.api.datastore.DatastoreService datastore,
                                com.google.appengine.api.blobstore.BlobKey blobKey,
                                java.lang.String entityKind,
                                java.lang.String mimeType,
                                long currentTime,
                                java.lang.String fileName,
                                java.lang.String creationHandle)

### newReadableInstance

    public static FileMetadata newReadableInstance(LocalFileService localFileService,
                                                   Clock clock,
                                                   ParsedFileName parsedName)

  Returns a new instance of `FileMetadata` if possible. This method is called in response to an Open-for-Read request in the case that no meta-data is found for the requested file in the in-memory cache. If it is determined that the given file name corresponds to an existing, finalized file, then an instance of `FileMetadata` will be returned. Otherwise `null` will be returned.

  Returns:
    An instance of `FileMetadata` or `null` if no corresponding entity could be found in the datastore.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD