RedlandNamespace Class Reference
Inherits from | NSObject |
Conforms to | NSCopying |
Declared in | RedlandNamespace.h RedlandNamespace.m |
Overview
Convenience class for generating namespaced nodes, URIs, and strings.
Instances of RedlandNamespace are helper objects which make it very easy to create RedlandNodes, RedlandURIs, NSStrings, or NSURLs with a common namespace prefix. Please note that this class is still experimental and its API is subject to change.
Tasks
-
shortName
< The namespace prefix of the receiver
property -
+ initGlobalNamespaces
< The shortName of the receiver
-
+ namespaceWithShortName:
Returns a pre-registered instance with the given short name.
-
– initWithPrefix:shortName:
Initialises the receiver with a given URI prefix and short name.
-
– registerInstance
Registers the current instance so it can be retrieved by calling [RedlandNamespace namespaceWithShortName:].
-
– unregisterInstance
Removes the registration done by [RedlandNamespace registerInstance].
-
– node:
Returns a new RedlandNode of type resource whose URI value is the given suffix appended to the receiver’s namespace.
-
– URI:
Returns a new RedlandURI by appending the given suffix to the receiver’s namespace.
-
– URL:
Returns a new NSURL by appending the given suffix to the receiver’s namespace.
-
– string:
Returns a new NSString by appending the given suffix to the receiver’s namespace.
-
– containsURIString:
Returns YES if the given NSString begins with the same prefix as the receiver.
-
– containsNode:
Returns YES if the resource URI of the given RedlandNode begins with the same prefix as the receiver.
-
– containsURI:
Returns YES if the given RedlandURI begins with the same prefix as the receiver.
-
– localNameOfURIString:
Returns the local name of the given string in the receiver’s namespace.
-
– localNameOfNode:
Returns the local name of the given RedlandNode in the receiver’s namespace.
-
– localNameOfURI:
Returns the local name of the given RedlandURI in the receiver’s namespace.
Class Methods
initGlobalNamespaces
< The shortName of the receiver
+ (void)initGlobalNamespaces
Discussion
< The shortName of the receiver
Declared In
RedlandNamespace.h
namespaceWithShortName:
Returns a pre-registered instance with the given short name.
+ (RedlandNamespace *)namespaceWithShortName:(NSString *)aName
Discussion
Returns a pre-registered instance with the given short name.
Warning: This method allows you to retrieve previously registered namespace instances by their short name. For example, if you call [RDFSyntaxNS registerInstance], you can then get this instance by calling: [RedlandNamespace namespaceWithShortName:\@“rdf”].
Warning: Under ARC, this method returns a strong reference.
Declared In
RedlandNamespace.m
Instance Methods
URI:
Returns a new RedlandURI by appending the given suffix to the receiver’s namespace.
- (RedlandURI *)URI:(NSString *)suffix
Parameters
- suffix
The string to append to the receiver’s namespace prefix
Return Value
The created RedlandURI instance
Discussion
Returns a new RedlandURI by appending the given suffix to the receiver’s namespace.
Declared In
RedlandNamespace.m
URL:
Returns a new NSURL by appending the given suffix to the receiver’s namespace.
- (NSURL *)URL:(NSString *)suffix
Parameters
- suffix
The string to append to the receiver’s namespace prefix
Return Value
The created NSURL instance
Discussion
Returns a new NSURL by appending the given suffix to the receiver’s namespace.
Declared In
RedlandNamespace.m
containsNode:
Returns YES if the resource URI of the given RedlandNode begins with the same prefix as the receiver.
- (BOOL)containsNode:(RedlandNode *)node
Return Value
YES if the node is a resource node and the prefixes are equal, otherwise NO.
Discussion
Returns YES if the resource URI of the given RedlandNode begins with the same prefix as the receiver.
Declared In
RedlandNamespace.m
containsURI:
Returns YES if the given RedlandURI begins with the same prefix as the receiver.
- (BOOL)containsURI:(RedlandURI *)aURI
Return Value
YES if the prefixes are equal, otherwise NO.
Discussion
Returns YES if the given RedlandURI begins with the same prefix as the receiver.
Declared In
RedlandNamespace.m
containsURIString:
Returns YES if the given NSString begins with the same prefix as the receiver.
- (BOOL)containsURIString:(NSString *)qName
Return Value
YES if the prefixes are equal, otherwise NO.
Discussion
Returns YES if the given NSString begins with the same prefix as the receiver.
Declared In
RedlandNamespace.m
initWithPrefix:shortName:
Initialises the receiver with a given URI prefix and short name.
- (id)initWithPrefix:(NSString *)aPrefix shortName:(NSString *)aName
Parameters
- aPrefix
The URI prefix string which will be prepended to objects created by the new instance, e.g. http://purl.org/dc/elements/1.1/
- aName
The short name for this namespace, e.g. dc
Return Value
The newly initialised instance
Discussion
Initialises the receiver with a given URI prefix and short name.
Warning: The shortName is currently not used, but may be used later to provide automatic shortening of URIs.
Declared In
RedlandNamespace.m
localNameOfNode:
Returns the local name of the given RedlandNode in the receiver’s namespace.
- (NSString *)localNameOfNode:(RedlandNode *)aNode
Parameters
- aNode
A RedlandNode of type resource
Return Value
A string generated by stripping the receiver’s namespace prefix from the beginning of aNode’s resource URI. If the node’s resource URI does not begin with the same prefix as the receiver, or if the node is not of type resource, nil is returned.
Discussion
Returns the local name of the given RedlandNode in the receiver’s namespace.
Declared In
RedlandNamespace.m
localNameOfURI:
Returns the local name of the given RedlandURI in the receiver’s namespace.
- (NSString *)localNameOfURI:(RedlandURI *)aURI
Parameters
- aURI
Return Value
A string generated by stripping the receiver’s namespace prefix from the beginning of aURI. If the URI does not begin with the same prefix as the receiver, nil is returned.
Discussion
Returns the local name of the given RedlandURI in the receiver’s namespace.
Declared In
RedlandNamespace.m
localNameOfURIString:
Returns the local name of the given string in the receiver’s namespace.
- (NSString *)localNameOfURIString:(NSString *)qName
Parameters
- qName
A URI string
Return Value
A string generated by stripping the receiver’s namespace prefix from the beginning of aString. If the string does not begin with the same prefix as the receiver, nil is returned.
Discussion
Returns the local name of the given string in the receiver’s namespace.
Declared In
RedlandNamespace.m
node:
Returns a new RedlandNode of type resource whose URI value is the given suffix appended to the receiver’s namespace.
- (RedlandNode *)node:(NSString *)suffix
Parameters
- suffix
The string to append to the receiver’s namespace prefix
Return Value
The created RedlandNode instance
Discussion
Returns a new RedlandNode of type resource whose URI value is the given suffix appended to the receiver’s namespace.
Declared In
RedlandNamespace.m
registerInstance
Registers the current instance so it can be retrieved by calling [RedlandNamespace namespaceWithShortName:].
- (void)registerInstance
Discussion
Registers the current instance so it can be retrieved by calling [RedlandNamespace namespaceWithShortName:].
Warning: Raises an exception if there is already an instance registered for the receiver’s shortName. The receiver automatically unregisters itself when it is deallocated.
Declared In
RedlandNamespace.m
string:
Returns a new NSString by appending the given suffix to the receiver’s namespace.
- (NSString *)string:(NSString *)suffix
Parameters
- suffix
The string to append to the receiver’s namespace prefix
Return Value
The created NSString instance
Discussion
Returns a new NSString by appending the given suffix to the receiver’s namespace.
Declared In
RedlandNamespace.m
unregisterInstance
Removes the registration done by [RedlandNamespace registerInstance].
- (void)unregisterInstance
Discussion
Removes the registration done by [RedlandNamespace registerInstance].
Warning: Does nothing if the receiver is not registered.
Warning: Because “+namespaceWithShortName:” returns a strong reference under ARC, we have to query “GlobalNamespaceDict” directly instead since this method is called from within “dealloc”.
Declared In
RedlandNamespace.m