Class TBrookMediaTypes

Unit

Declaration

type TBrookMediaTypes = class abstract(TBrookHandledPersistent)

Description

Cached abstract class to register, add, remove, find a media type.

Hierarchy

Overview

Methods

Public constructor Create; virtual;
Public destructor Destroy; override;
Public class function GetRegisterAlias: string; virtual;
Public class function GetDescription: string; virtual; abstract;
Public class function IsValid(const AType: string): Boolean; static; inline;
Public class function IsText(const AType: string): Boolean; static; inline;
Public class function IsExt(const AExt: string): Boolean; static; inline;
Public class function NormalizeExt(const AExt: string): string; static; inline;
Public procedure Prepare; virtual; abstract;
Public procedure Add(const AExt, AType: string); virtual;
Public procedure Remove(const AExt: string); virtual;
Public function TryType(const AExt: string; out AType: string): Boolean; virtual;
Public function Find(const AExt, ADefType: string): string; overload; virtual;
Public function Find(const AExt: string): string; overload; virtual;
Public function Count: Integer; virtual;
Public procedure Clear; virtual;

Properties

Public property DefaultType: string read FDefaultType write SetDefaultType;
Public property Prepared: Boolean read IsPrepared;

Description

Methods

Public constructor Create; virtual;

Creates an instance of TBrookMediaTypes.

Public destructor Destroy; override;

Destroys an instance of TBrookMediaTypes.

Public class function GetRegisterAlias: string; virtual;

Returns the alias name for media type source.

Returns

Media type source alias.

Public class function GetDescription: string; virtual; abstract;

Returns the description of the media types source.

Returns

Description of the media types source.

Public class function IsValid(const AType: string): Boolean; static; inline;

Returns True if a string represents a media type, e.g 'text/plain'.

Parameters
AType[in]
Media type identifier.
Returns

True if a string represents a media type.

Public class function IsText(const AType: string): Boolean; static; inline;

Returns True if a string represents a text media type, e.g. 'text/plain'.

Parameters
AType[in]
Media type identifier.
Returns

True if a string represents a text media type.

Public class function IsExt(const AExt: string): Boolean; static; inline;

Returns True if a string represents a file extension, e.g. 'text/plain'.

Parameters
AExt[in]
File extension.
Returns

True if a string represents a file extension.

Public class function NormalizeExt(const AExt: string): string; static; inline;

Normalizes file extension by adding a dot, e.g. a 'pas' will be normalized to '.pas'.

Parameters
AExt[in]
File extension.
Returns

Normalized file extension.

Public procedure Prepare; virtual; abstract;

Prepares the media types source.

Public procedure Add(const AExt, AType: string); virtual;

Adds a new media type to the cache.

Parameters
AExt[in]
File extension.
AType[in]
Media type identifier.
Public procedure Remove(const AExt: string); virtual;

Removes a media type from the cache.

Parameters
AExt[in]
File extension.
Public function TryType(const AExt: string; out AType: string): Boolean; virtual;

If the cache is not prepared yet, this method prepares it automatically and tries to find a media type identifier by file extension.

Parameters
AExt[in]
File extension.
AType[in]
Media type identifier.
Returns

True if the media type identifier is found.

Public function Find(const AExt, ADefType: string): string; overload; virtual;

Finds a media type identifier by file extension. If the cache is not prepared yet, this method prepares it automatically. If a media type identifier is not found, the ADefType is returned instead.

Parameters
AExt[in]
File extension.
ADefType[in]
Default media type identifier.
Returns

Media type identifier.

Public function Find(const AExt: string): string; overload; virtual;

Finds a media type identifier by file extension. If the cache is not prepared yet, this method prepares it automatically. If a media type identifier is not found, the DefaultType is returned instead.

Parameters
AExt[in]
File extension.
Returns

Media type identifier.

Public function Count: Integer; virtual;

Counts all media type identifiers present in the cache.

Returns

All media type identifiers present in the cache.

Public procedure Clear; virtual;

Clears all media type identifiers present in the cache.

Properties

Public property DefaultType: string read FDefaultType write SetDefaultType;

Default media type identifier returned by Find.

Public property Prepared: Boolean read IsPrepared;

True if the media types cache is prepared.


Generated by PasDoc 0.16.0.