Format
class Format
Class the represents an RDF file format.
For each format, the name, label, URIs and associated MIME Types are stored. A single parser and serialiser can also be registered to each format.
Methods
Get a list of format names
Get a list of all the registered formats
Generates an HTTP Accept header string
Convert array of types to Accept header value
Check if a named graph exists
Register a new format
Remove a format from the registry
Class method to register a parser class to a format name
Class method to register a serialiser class to a format name
Attempt to guess the document format from some content.
This constructor is for internal use only.
Get the name of a format object
Get the label for a format object
Set the label for a format object
Get the URI for a format object
Set the URI for a format object
Get the default registered mime type for a format object
Get all the registered mime types for a format object
Set the MIME Types for a format object
Get the default registered file extension (filename suffix) for a format object
Get all the registered file extensions (filename suffix) for a format object
Set the file format extensions (filename suffix) for a format object
Set the parser to use for a format
Get the name of the class to use to parse the format
Create a new parser to parse this format
Set the serialiser to use for a format
Get the name of the class to use to serialise the format
Create a new serialiser to parse this format
Magic method to return the name of the format when casted to string
Details
at line 66
static array
getNames()
Get a list of format names
at line 75
static array
getFormats()
Get a list of all the registered formats
at line 94
static string
getHttpAcceptHeader(array $extraTypes = array())
Generates an HTTP Accept header string
The string will contain all of the MIME Types that we are able to parse.
It is also possible to specify additional MIME types in the form array('text/plain' => 0.5) where 0.5 is the q value for that type. The types are sorted by q value before constructing the string.
at line 111
static string
formatAcceptHeader(array $accepted_types)
Convert array of types to Accept header value
at line 136
static bool
formatExists(string $name)
Check if a named graph exists
at line 149
static Format
getFormat(string $query)
Get a EasyRdf\Format from a name, uri or mime type
at line 183
static Format
register(string $name, string $label = null, string $uri = null, array|string $mimeTypes = array(), array|string $extensions = array())
Register a new format
at line 211
static
unregister(string $name)
Remove a format from the registry
at line 221
static
registerParser(string $name, string $class)
Class method to register a parser class to a format name
at line 234
static
registerSerialiser(string $name, string $class)
Class method to register a serialiser class to a format name
at line 253
static Format
guessFormat(string $data, string $filename = null)
Attempt to guess the document format from some content.
If $filename is given, then the suffix is first used to guess the format.
If the document format is not recognised, null is returned.
at line 301
__construct(string $name)
This constructor is for internal use only.
To create a new format, use the register method.
at line 311
string
getName()
Get the name of a format object
at line 320
string
getLabel()
Get the label for a format object
at line 332
string|null
setLabel(string $label)
Set the label for a format object
at line 350
string
getUri()
Get the URI for a format object
at line 362
string|null
setUri(string $uri)
Set the URI for a format object
at line 380
string
getDefaultMimeType()
Get the default registered mime type for a format object
at line 393
array
getMimeTypes()
Get all the registered mime types for a format object
at line 402
setMimeTypes(string|array $mimeTypes)
Set the MIME Types for a format object
at line 418
string
getDefaultExtension()
Get the default registered file extension (filename suffix) for a format object
at line 429
array
getExtensions()
Get all the registered file extensions (filename suffix) for a format object
at line 438
setExtensions(mixed $extensions)
Set the file format extensions (filename suffix) for a format object
at line 456
setParserClass(string $class)
Set the parser to use for a format
at line 474
string
getParserClass()
Get the name of the class to use to parse the format
at line 484
object
newParser()
Create a new parser to parse this format
at line 501
setSerialiserClass(string $class)
Set the serialiser to use for a format
at line 519
string
getSerialiserClass()
Get the name of the class to use to serialise the format
at line 529
object
newSerialiser()
Create a new serialiser to parse this format
at line 544
string
__toString()
Magic method to return the name of the format when casted to string