/** * Get the value of an attribute. * * @param string $name The name of an attribute. * @return string The value of the attribute. If it does not exist, returns `null'. * @access public */ public function getAttribute($name) { SERVICES_HYPERESTRAIER_DEBUG && Services_HyperEstraier_Utility::checkTypes(array($name, 'string')); return isset($this->_attrs[$name]) ? $this->_attrs[$name] : null; }
/** * Get the value of hint information. * * @param string $key The key of a hint. * "VERSION", "NODE", "HIT", "HINT#n", "DOCNUM", * "WORDNUM", "TIME", "TIME#n", "LINK#n", and "VIEW" * are provided for keys. * @return string The hint. If the key does not exist, returns `null'. * @access public */ public function getHint($key) { SERVICES_HYPERESTRAIER_DEBUG && Services_HyperEstraier_Utility::checkTypes(array($key, 'string')); return isset($this->_hints[$key]) ? $this->_hints[$key] : null; }
/** * Search for documents corresponding a condition. * * @param object $cond Services_HyperEstraier_Condition * which is a condition object. * @param int $depth The depth of meta search. * @return object Services_HyperEstraier_NodeResult * A node result object. * On error, returns `null'. * @access public */ public function search(Services_HyperEstraier_Condition $cond, $depth) { SERVICES_HYPERESTRAIER_DEBUG && Services_HyperEstraier_Utility::checkTypes(array($depth, 'integer')); $this->_status = -1; if (!$this->_url) { return null; } $turl = $this->_url . '/search'; $reqheads = array('content-type' => 'application/x-www-form-urlencoded'); $reqbody = Services_HyperEstraier_Utility::conditionToQuery($cond, $depth, $this->_wwidth, $this->_hwidth, $this->_awidth); $res = Services_HyperEstraier_Utility::shuttleUrl($turl, $this->_auth, $this->_pxhost, $this->_pxport, $this->_timeout, $reqheads, $reqbody); if (!$res) { return null; } $this->_status = $res->getResponseCode(); if ($res->isError()) { return null; } $lines = explode("\n", $res->getResponseBody()); if (count($lines) == 0) { return null; } $docs = array(); $hints = array(); $border = $lines[0]; $isend = false; $lnum = 1; $llen = count($lines); $blen = strlen($border); while ($lnum < $llen) { $line = $lines[$lnum]; $lnum++; if (strlen($line) >= $blen && strpos($line, $border) === 0) { if (substr($line, $blen) == ':END') { $isend = true; } break; } if (strpos($line, "\t")) { list($key, $value) = explode("\t", $line, 2); $hints[$key] = $value; } } $snum = $lnum; while (!$isend && $lnum < $llen) { $line = $lines[$lnum]; $lnum++; if (strlen($line) >= $blen && strpos($line, $border) === 0) { if ($lnum > $snum) { $rdattrs = array(); $sb = ''; $rdvector = ''; $rlnum = $snum; while ($rlnum < $lnum - 1) { $rdline = trim($lines[$rlnum]); $rlnum++; if (strlen($rdline) == 0) { break; } if (substr($rdline, 0, 1) == '%') { $lidx = strpos($rdline, "\t"); if (strpos($rdline, '%VECTOR') === 0 && $lidx) { $rdvector = substr($rdline, $lidx + 1); } } else { if (strpos($rdline, '=')) { list($key, $value) = explode('=', $rdline, 2); $rdattrs[$key] = $value; } } } while ($rlnum < $lnum - 1) { $rdline = $lines[$rlnum]; $rlnum++; $sb .= $rdline . "\n"; } $rduri = $rdattrs['@uri']; $rdsnippet = $sb; if ($rduri) { $rdoc = new Services_HyperEstraier_ResultDocument($rduri, $rdattrs, $rdsnippet, $rdvector); $docs[] = $rdoc; } } $snum = $lnum; if (substr($line, $blen) == ':END') { $isend = true; } } } if (!$isend) { return null; } return new Services_HyperEstraier_NodeResult($docs, $hints); }
/** * Set the mask of targets of meta search. * * @param int $mask A masking number. * 1 means the first target, 2 means the second target, * 4 means the third target, and power values of 2 and * their summation compose the mask. * @return void * @access public */ public function setMask($mask) { SERVICES_HYPERESTRAIER_DEBUG && Services_HyperEstraier_Utility::checkTypes(array($mask, 'integer')); $this->_mask = $mask; }