ETUTI class documentation

Authors

Eric Wasylishen (ewasylishen@gmail.com)
A type class to represent data types and aggregate various type representations into a common type model (Uniform Type Identifier)

Copyright: (C) 2009 Eric Wasylishen


Contents -

  1. Software documentation for the ETUTI class
  2. ETUTI constants

Software documentation for the ETUTI class

ETUTI : NSObject

Declared in:
ETUTI.h
Conforms to:
NSCopying

@group Uniform Type Identifier

ETUTI objects represent Uniform Type Identifiers (UTIs), strings written in reverse-DNS notation (e.g. org.etoile.group) which are used to describe data type. UTIs support multiple inheritance to indicate that certain types are refinements of one or more parent types.

The ETUTI implementation also integrates with the Objective-C runtime. UTI's can be automatically generated for a given class, which are given the form org.etoile-project.objc.class.ClassName

EtoileFoundation provides a built-in UTI library and some class bindings (UTI supertypes to which ObjC classes conforms to). See UTIDefinitions.plist and ClassBindings.plist in the EtoileFoundation framework resources.

Additional UTIs and class bindings can be provided in third-party applications or frameworks. At launch time, ETUTI loads any UTIDefinitions.plist and ClassBindings.plist present in the main bundle and loaded frameworks, and merges the content into its runtime UTI database. You cannot redefine a UTI built into EtoileFoundation UTIDefinitions.plist.

Method summary

registerTypeWithString: description: supertypeStrings: typeTags: 

+ (ETUTI*) registerTypeWithString: (NSString*)aString description: (NSString*)description supertypeStrings: (NSArray*)supertypeNames typeTags: (NSDictionary*)tags;

Registers a UTI in the UTI database. UTIs registered with this method are not currently persisted.

A type tag dictionary can be passed to express how the UTI is mapped to other type identification models. EUTI currently supports two other type identification models: file extensions and MIME types. All MIME types and file extensions belongs to two tag classes (encoded as UTI), respectively kETUTITagClassMIMEType and kETUTITagClassFileExtension. Finally each entry in a type tag dictionary must be an array. Here is an example of a valid type tag dictionary:

 [NSDictionary dictionaryWithObjectsAndKeys: 
 	[NSArray arrayWithObject: @"image/tiff"], kETUTITagClassMIMEType,
 	[NSArray arrayWithObjects: @"tif", @"tiff", nil], kETUTITagClassFileExtension, nil]
 

See also -fileExtensions and -MIMETypes .


registerTypesFromBundle: 

+ (void) registerTypesFromBundle: (NSBundle*)aBundle;

Registers additional UTIs and class bindings in the UTI database by loading any UTIDefinitions.plist and ClassBindings.plist present in the bundle resources directory.

UTIs and class bindings registered with this method are not persisted.


transientTypeWithSupertypeStrings: 

+ (ETUTI*) transientTypeWithSupertypeStrings: (NSArray*)supertypeNames;

Returns a "transient" or anonymous ETUTI object based on the given UTI string representations as supertypes.

Useful in combination with conformsToUTI: for checking whether an unknown UTI conforms to any UTI in a set (the supertypes specified for the transient UTI.)


transientTypeWithSupertypes: 

+ (ETUTI*) transientTypeWithSupertypes: (NSArray*)supertypes;

Returns a "transient" or anonymous ETUTI object based on the given UTI objects as supertypes.

See also +transientTypeWithSupertypeStrings:


typeWithClass: 

+ (ETUTI*) typeWithClass: (Class)aClass;

Returns an ETUTI object representing the given class. Calling -supertypes will return a UTI representing the superclass of the class, in addition to any supertypes specified for the class in UTIDefinitions.plist.

Note that it is not necessary to list Objective-C classes in UTIDefinitons.plist; ETUTI objects for ObjC classes are created dynamically, but UTIDefinitions.plist can be used to add supplemental supertypes.


typeWithFileExtension: 

+ (ETUTI*) typeWithFileExtension: (NSString*)anExtension;
Description forthcoming.

typeWithMIMEType: 

+ (ETUTI*) typeWithMIMEType: (NSString*)aMIME;
Description forthcoming.

typeWithPath: 

+ (ETUTI*) typeWithPath: (NSString*)aPath;

Returns an ETUTI object representing the type of the file located at the specified local path.


typeWithString: 

+ (ETUTI*) typeWithString: (NSString*)aString;

@taskunit Initialization

Returns an ETUTI object for the given UTI string (e.g. public.audio). The given UTI string must either:

  • be in the UTIDefinitions.plist file
  • or have been registered with the registertypeWithString:description:supertypes: method
  • or be a UTI of the form org.etoile-project.objc.class.ClassName where ClassName is a valid Objective-C class

Otherwise, nil is returned.


MIMETypes 

- (NSArray*) MIMETypes;

Returns an array of MIME types which refer to the same data type as the receiver.


allSubtypes 

- (NSArray*) allSubtypes;

Returns all known UTI objects which conform to the receiver.


allSupertypes 

- (NSArray*) allSupertypes;

Returns all known UTI objects which are supertypes of the receiver (all UTIs which the receiver conforms to).

The immediate supertypes comes first in the returned array.
Types higher in the hierarchy follow. The ordering among the supertypes beside the immediate supertypes is undetermined (due to multiple inheritance).


classValue 

- (Class) classValue;

Returns the ObjC class the UTI represents, or Nil if the UTI does not represent a class registered in the runtime.

See also +typeWithClass: .


conformsToType: 

- (BOOL) conformsToType: (ETUTI*)aType;

@taskunit Type Conformance

Tests whether or not the receiver conforms to aType (i.e. aType is a supertype of the receiver, possibly many levels away).


fileExtensions 

- (NSArray*) fileExtensions;

Returns an array of file extensions (if any) which refer to the same data type as the receiver.


stringValue 

- (NSString*) stringValue;

@taskunit Type Representations and Informations

Returns the string representation of the UTI (e.g. public.audio).


subtypes 

- (NSArray*) subtypes;

Returns the UTI objects which have the receiver as an immediate supertype.


supertypes 

- (NSArray*) supertypes;

@taskunit Type Inheritance

Returns the UTI objects which are immediate supertypes of the receiver.


typeDescription 

- (NSString*) typeDescription;

Returns a natural language description of the receiver.


ETUTI constants

kETUTITagClassFileExtension

NSString* const kETUTITagClassFileExtension;

Key to identify the file extension array in a type tag dictionary.


kETUTITagClassMIMEType

NSString* const kETUTITagClassMIMEType;

Key to identify the MIME type string array in a type tag dictionary.