com.flexive.shared.value
Class BinaryDescriptor

java.lang.Object
  extended by com.flexive.shared.value.BinaryDescriptor
All Implemented Interfaces:
java.io.Serializable

public class BinaryDescriptor
extends java.lang.Object
implements java.io.Serializable

Descriptor for binaries (immutable). Qualities and Versions are currently only planned features but not yet functional.

Author:
Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
See Also:
Serialized Form

Nested Class Summary
static class BinaryDescriptor.PreviewSizes
          Enumeration of all available preview sizes.
 
Field Summary
static java.lang.String EMPTY
           
static int PREVIEW1_BOX
          For images: box scaled size for preview 1
static int PREVIEW2_BOX
          For images: box scaled size for preview 2
static int PREVIEW3_BOX
          For images: box scaled size for preview 3
static int SCREENVIEW_HEIGHT
           
static int SCREENVIEW_WIDTH
          For images: scaled size for screenviews (1024x768)
static int SYS_AUDIO
           
static int SYS_DOC
           
static int SYS_HTML
           
static int SYS_ICAL
           
static int SYS_INFO
           
static int SYS_NOACCESS
           
static int SYS_PDF
           
static int SYS_PPT
           
static int SYS_SELECTLIST_DEFAULT
           
static int SYS_TXT
           
static int SYS_UNKNOWN
           
static int SYS_VIDEO
           
static int SYS_XLS
           
 
Constructor Summary
  BinaryDescriptor()
          Constructor for a new empty binary
protected BinaryDescriptor(BinaryUploadPayload payload, java.lang.String name, java.lang.String mimeType)
          Internal Constructor (for new Binaries with unknown size)
  BinaryDescriptor(java.util.List<com.flexive.stream.ServerLocation> server, long id, int version, int quality, long creationTime, java.lang.String name, long size, java.lang.String metadata, java.lang.String mimeType, boolean image, double resolution, int width, int height, java.lang.String md5sum)
          Constructor - used for loading from the content engine
  BinaryDescriptor(java.lang.String handle)
          Constructor (for new Binaries)
  BinaryDescriptor(java.lang.String name, java.io.InputStream stream)
          Constructor (for new Binaries with unknown length - use with care since it will have to create a temp file to determine length!)
  BinaryDescriptor(java.lang.String name, long streamLength, java.io.InputStream stream)
          Constructor (for new Binaries)
  BinaryDescriptor(java.lang.String name, long streamLength, java.lang.String mimeType, java.io.InputStream stream)
          Constructor (for new Binaries)
  BinaryDescriptor(java.lang.String name, java.lang.String mimeType, java.io.InputStream stream)
          Constructor (for new Binaries with unknown size)
  BinaryDescriptor(java.lang.String handle, java.lang.String name, long size, java.lang.String mimeType, java.lang.String metadata)
          Constructor for new Binaries in prepareSave process ..
  BinaryDescriptor(java.lang.String handle, java.lang.String name, long size, java.lang.String mimeType, java.lang.String metadata, java.lang.String md5sum)
          Constructor for new Binaries in identifyAndTransferTransitBinary process ..
 
Method Summary
 void download(java.io.OutputStream stream)
          Downloads the binary to the given stream.
 void download(java.io.OutputStream stream, BinaryDescriptor.PreviewSizes size)
          Downloads the binary in the requested size (original or preview images if available) to the given stream.
 boolean equals(java.lang.Object obj)
          
 long getCreationTime()
          Getter for the creation timestamp
 java.lang.String getHandle()
          Getter for the handle
 int getHeight()
          If binary is an image, getter for the height in pixel
 long getId()
          Getter for the binary id (not content instance id!)
 java.io.InputStream getInputStream()
          Get the (original) binary as InputStream
 java.io.InputStream getInputStream(BinaryDescriptor.PreviewSizes size)
          Get the binary as InputStream for a requested preview size
 java.lang.String getMd5sum()
          Get the MD5 checksum of the binary, only available after a binary has been loaded from the storage!
 java.lang.String getMetadata()
          Getter for optional metadata (usually XML)
 java.lang.String getMimeType()
          Getter for the mime type (if available)
 java.lang.String getName()
          Name of the binary
 int getQuality()
          Getter for the quality
 double getResolution()
          If binary is an image, getter for the resolution in dpi
 long getSize()
          Getter for the binary size in bytes
 int getVersion()
          Getter for the binary version
 int getWidth()
          If binary is an image, getter for the width in pixel
 int hashCode()
          
 boolean isEmpty()
          Is this BinaryDescriptor empty?
 boolean isImage()
          Is this binary an image?
 boolean isNewBinary()
          Is this a new binary?
 void setId(long binaryId)
          Set the binary id, only allowed if not assigned previously
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SYS_UNKNOWN

public static final int SYS_UNKNOWN
See Also:
Constant Field Values

SYS_NOACCESS

public static final int SYS_NOACCESS
See Also:
Constant Field Values

SYS_AUDIO

public static final int SYS_AUDIO
See Also:
Constant Field Values

SYS_DOC

public static final int SYS_DOC
See Also:
Constant Field Values

SYS_ICAL

public static final int SYS_ICAL
See Also:
Constant Field Values

SYS_INFO

public static final int SYS_INFO
See Also:
Constant Field Values

SYS_PDF

public static final int SYS_PDF
See Also:
Constant Field Values

SYS_TXT

public static final int SYS_TXT
See Also:
Constant Field Values

SYS_VIDEO

public static final int SYS_VIDEO
See Also:
Constant Field Values

SYS_XLS

public static final int SYS_XLS
See Also:
Constant Field Values

SYS_PPT

public static final int SYS_PPT
See Also:
Constant Field Values

SYS_HTML

public static final int SYS_HTML
See Also:
Constant Field Values

SYS_SELECTLIST_DEFAULT

public static final int SYS_SELECTLIST_DEFAULT
See Also:
Constant Field Values

EMPTY

public static final java.lang.String EMPTY
See Also:
Constant Field Values

PREVIEW1_BOX

public static final int PREVIEW1_BOX
For images: box scaled size for preview 1

See Also:
Constant Field Values

PREVIEW2_BOX

public static final int PREVIEW2_BOX
For images: box scaled size for preview 2

See Also:
Constant Field Values

PREVIEW3_BOX

public static final int PREVIEW3_BOX
For images: box scaled size for preview 3

See Also:
Constant Field Values

SCREENVIEW_WIDTH

public static final int SCREENVIEW_WIDTH
For images: scaled size for screenviews (1024x768)

Since:
3.1
See Also:
Constant Field Values

SCREENVIEW_HEIGHT

public static final int SCREENVIEW_HEIGHT
See Also:
Constant Field Values
Constructor Detail

BinaryDescriptor

public BinaryDescriptor()
Constructor for a new empty binary


BinaryDescriptor

public BinaryDescriptor(java.lang.String handle)
Constructor (for new Binaries)

Parameters:
handle - binary_transit handle

BinaryDescriptor

public BinaryDescriptor(java.lang.String handle,
                        java.lang.String name,
                        long size,
                        java.lang.String mimeType,
                        java.lang.String metadata)
Constructor for new Binaries in prepareSave process ..

Parameters:
handle - handle
name - name of the binary
size - size in bytes
mimeType - MIME type
metadata - xml meta data

BinaryDescriptor

public BinaryDescriptor(java.lang.String handle,
                        java.lang.String name,
                        long size,
                        java.lang.String mimeType,
                        java.lang.String metadata,
                        java.lang.String md5sum)
Constructor for new Binaries in identifyAndTransferTransitBinary process ..

Parameters:
handle - handle
name - name of the binary
size - size in bytes
mimeType - MIME type
metadata - xml meta data
md5sum - MD5 checksum

BinaryDescriptor

public BinaryDescriptor(java.lang.String name,
                        long streamLength,
                        java.io.InputStream stream)
                 throws FxStreamException
Constructor (for new Binaries)

Parameters:
name - name of the binary
streamLength - expected size of the binary
stream - an open input stream for the binary to upload
Throws:
FxStreamException - on upload errors

BinaryDescriptor

public BinaryDescriptor(java.lang.String name,
                        long streamLength,
                        java.lang.String mimeType,
                        java.io.InputStream stream)
                 throws FxStreamException
Constructor (for new Binaries)

Parameters:
name - name of the binary
streamLength - expected size of the binary
mimeType - the mime type to be used if auto-detection fails
stream - an open input stream for the binary to upload
Throws:
FxStreamException - on upload errors
Since:
3.1

BinaryDescriptor

public BinaryDescriptor(java.lang.String name,
                        java.lang.String mimeType,
                        java.io.InputStream stream)
                 throws FxStreamException
Constructor (for new Binaries with unknown size)

Parameters:
name - name of the binary
mimeType - the MIME type to be used, regardless of the stream content
stream - an open input stream for the binary to upload
Throws:
FxStreamException - on upload errors
Since:
3.1

BinaryDescriptor

protected BinaryDescriptor(BinaryUploadPayload payload,
                           java.lang.String name,
                           java.lang.String mimeType)
Internal Constructor (for new Binaries with unknown size)

Parameters:
payload - payload from the streaming server to read the actual size
name - name of the binary
mimeType - the MIME type to be used, regardless of the stream content
Since:
3.1

BinaryDescriptor

public BinaryDescriptor(java.lang.String name,
                        java.io.InputStream stream)
                 throws FxStreamException
Constructor (for new Binaries with unknown length - use with care since it will have to create a temp file to determine length!)

Parameters:
name - name of the binary
stream - an open input stream for the binary to upload
Throws:
FxStreamException - on upload errors

BinaryDescriptor

public BinaryDescriptor(java.util.List<com.flexive.stream.ServerLocation> server,
                        long id,
                        int version,
                        int quality,
                        long creationTime,
                        java.lang.String name,
                        long size,
                        java.lang.String metadata,
                        java.lang.String mimeType,
                        boolean image,
                        double resolution,
                        int width,
                        int height,
                        java.lang.String md5sum)
Constructor - used for loading from the content engine

Parameters:
server - server location
id - binary id
version - binary version
quality - quality
creationTime - timestamp when the binary data was created in the storage
name - name
size - size
metadata - xml metadata
mimeType - mime type
image - binary is an image?
resolution - resoltion (if image and detected)
width - width (if image and detected)
height - height (if image and detected)
md5sum - MD5 checksum of the binary
Method Detail

setId

public void setId(long binaryId)
Set the binary id, only allowed if not assigned previously

Parameters:
binaryId - binary id

download

public void download(java.io.OutputStream stream)
              throws FxStreamException
Downloads the binary to the given stream. The stream won't be flushed or closed!

Parameters:
stream - stream used for download
Throws:
FxStreamException - on errors

download

public void download(java.io.OutputStream stream,
                     BinaryDescriptor.PreviewSizes size)
              throws FxStreamException
Downloads the binary in the requested size (original or preview images if available) to the given stream. The stream won't be flushed or closed!

Parameters:
stream - stream used for download
size - requested size (original or preview images if available)
Throws:
FxStreamException - on errors

getInputStream

public java.io.InputStream getInputStream(BinaryDescriptor.PreviewSizes size)
                                   throws FxStreamException
Get the binary as InputStream for a requested preview size

Parameters:
size - requested preview size
Returns:
InputStream
Throws:
FxStreamException - on errors
Since:
3.1.4

getInputStream

public java.io.InputStream getInputStream()
                                   throws FxStreamException
Get the (original) binary as InputStream

Returns:
InputStream
Throws:
FxStreamException - on errors
Since:
3.1.4

isEmpty

public boolean isEmpty()
Is this BinaryDescriptor empty?

Returns:
BinaryDescriptor is empty

getHandle

public java.lang.String getHandle()
Getter for the handle

Returns:
handle

isNewBinary

public boolean isNewBinary()
Is this a new binary?

Returns:
new binary?

getId

public long getId()
Getter for the binary id (not content instance id!)

Returns:
binary id

getVersion

public int getVersion()
Getter for the binary version

Returns:
binary version

getQuality

public int getQuality()
Getter for the quality

Returns:
quality

getCreationTime

public long getCreationTime()
Getter for the creation timestamp

Returns:
creation timestamp

getName

public java.lang.String getName()
Name of the binary

Returns:
name of the binary

getSize

public long getSize()
Getter for the binary size in bytes

Returns:
binary size in bytes

getMd5sum

public java.lang.String getMd5sum()
Get the MD5 checksum of the binary, only available after a binary has been loaded from the storage!

Returns:
MD5 checksum of the binary
Since:
3.1

getMetadata

public java.lang.String getMetadata()
Getter for optional metadata (usually XML)

Returns:
optional metadata (usually XML)

getMimeType

public java.lang.String getMimeType()
Getter for the mime type (if available)

Returns:
mime type (if available)

isImage

public boolean isImage()
Is this binary an image?

Returns:
binary is an image

getResolution

public double getResolution()
If binary is an image, getter for the resolution in dpi

Returns:
resolution in dpi

getWidth

public int getWidth()
If binary is an image, getter for the width in pixel

Returns:
width in pixel

getHeight

public int getHeight()
If binary is an image, getter for the height in pixel

Returns:
height in pixel

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object