1 | <?php
|
---|
2 |
|
---|
3 | /* RDFInt - RDF Interfaces for PHP
|
---|
4 | * Copyright 2011 netlabs.org
|
---|
5 | * Author: Christian Langanke, Adrian Gschwend
|
---|
6 | *
|
---|
7 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
8 | * you may not use this file except in compliance with the License.
|
---|
9 | * You may obtain a copy of the License at
|
---|
10 | *
|
---|
11 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
12 | *
|
---|
13 | * Unless required by applicable law or agreed to in writing, software
|
---|
14 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
16 | * See the License for the specific language governing permissions and
|
---|
17 | * limitations under the License.
|
---|
18 | */
|
---|
19 |
|
---|
20 | namespace rdfa;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * \class SparqlEndpoint
|
---|
24 | * \brief This class implements the configuration class for SPARQL endpoints, used
|
---|
25 | * for creation of rdfa::SparqlQuery objects.
|
---|
26 | * \author Christian Langanke
|
---|
27 | * \author Adrian Gschwend
|
---|
28 | * \date 2011
|
---|
29 | */
|
---|
30 |
|
---|
31 | class SparqlEndpoint {
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Version of the class
|
---|
35 | */
|
---|
36 | const version = '1.0.0';
|
---|
37 | /**
|
---|
38 | * Name of the fDebug context
|
---|
39 | */
|
---|
40 | const debugcontext = 'RDFA_SPARQLENDPOINT';
|
---|
41 |
|
---|
42 | private $debugger;
|
---|
43 | private $aconfig;
|
---|
44 |
|
---|
45 | // ---------------------------------------
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Creates an endpoint configuration class instance.
|
---|
49 | */
|
---|
50 | public function __construct( $aconfig) {
|
---|
51 |
|
---|
52 | // setup debugger
|
---|
53 | $this->debugger = \fDebug::getInstance();
|
---|
54 |
|
---|
55 | // initialize instance vars
|
---|
56 | $this->aconfig = array();
|
---|
57 |
|
---|
58 | // store inital configuration
|
---|
59 | if (is_array( $aconfig)) {
|
---|
60 | $this->aconfig = $aconfig;
|
---|
61 | $debugmessage = "Creating endpoint configuration\n";
|
---|
62 | foreach ($aconfig as $name => $value) {
|
---|
63 | $debugmessage .= "$name=$value\n";
|
---|
64 | }
|
---|
65 | $this->debugger->sendMessage( $debugmessage, self::debugcontext);
|
---|
66 | } else {
|
---|
67 | $debugmessage = "Missing configuration parameters provided for endpoint configuration!";
|
---|
68 | $this->debugger->sendWarning( $debugmessage, self::debugcontext);
|
---|
69 | }
|
---|
70 |
|
---|
71 | } // public function __construct
|
---|
72 |
|
---|
73 | // ---------------------------------------
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * Sets an endpoint configuration values
|
---|
77 | */
|
---|
78 | public function setConfigurationValue( $name, $value) {
|
---|
79 | $this->debugger->sendMessage( "Send endpoint configuration value $name=$value", self::debugcontext);
|
---|
80 | $this->aconfig[ $name] = $value;
|
---|
81 | return;
|
---|
82 | }
|
---|
83 |
|
---|
84 | // ---------------------------------------
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * Gets an endpoint configuration values
|
---|
88 | */
|
---|
89 | public function getConfigurationValue( $name) {
|
---|
90 | if (!isset( $this->aconfig[ $name]))
|
---|
91 | return false;
|
---|
92 | else
|
---|
93 | return $this->aconfig[ $name];
|
---|
94 | }
|
---|
95 |
|
---|
96 | // ---------------------------------------
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * Queries the list of all endpoint configuration values
|
---|
100 | */
|
---|
101 | public function getConfigurationValues( ) {
|
---|
102 | return $this->aconfig;
|
---|
103 | }
|
---|
104 |
|
---|
105 | } // class SparqlEndpoint
|
---|
106 |
|
---|
107 | ?>
|
---|