Ejemplo n.º 1
0
 /**
  * Unpacks the elements in s and sets the attributes in the given
  * WellFormedName accordingly.
  * @param $s packed string
  * @param $wfn WellFormedName
  * @return The augmented WellFormedName.
  */
 private function unpack($s, WellFormedName $wfn)
 {
     // Parse out the five elements.
     $start = 1;
     $ed = "";
     $sw_edition = "";
     $t_sw = "";
     $t_hw = "";
     $oth = "";
     $end = strpos($s, "~", $start);
     if ($start == $end) {
         $ed = "";
     } else {
         $ed = substr($s, $start, $end - $start);
     }
     $start = $end + 1;
     $end = strpos($s, "~", $start);
     if ($start == $end) {
         $sw_edition = "";
     } else {
         $sw_edition = substr($s, $start, $end - $start);
     }
     $start = $end + 1;
     $end = strpos($s, "~", $start);
     if ($start == $end) {
         $t_sw = "";
     } else {
         $t_sw = substr($s, $start, $end - $start);
     }
     $start = $end + 1;
     $end = strpos($s, "~", $start);
     if ($start == $end) {
         $t_hw = "";
     } else {
         $t_hw = substr($s, $start, $end - $start);
     }
     $start = $end + 1;
     if ($start >= strlen($s)) {
         $oth = "";
     } else {
         $oth = substr($s, $start, strlen($s) - 1 - $start);
     }
     // Set each component in the WFN.
     try {
         $wfn->set("edition", $this->decode($ed));
         $wfn->set("sw_edition", $this->decode($sw_edition));
         $wfn->set("target_sw", $this->decode($t_sw));
         $wfn->set("target_hw", $this->decode($t_hw));
         $wfn->set("other", $this->decode($oth));
     } catch (Exception $e) {
         echo $e->getMessage() . "\n";
     }
     return $wfn;
 }
Ejemplo n.º 2
0
 public static function test()
 {
     // A few examples.
     echo "Testing CPENamingBind...<br>\n";
     $wfn = new WellFormedName("a", "microsoft", "internet_explorer", "8\\.0\\.6001", "beta", new LogicalValue("ANY"), "sp2", null, null, null, null);
     $wfn2 = new WellFormedName();
     $wfn2->set("part", "a");
     $wfn2->set("vendor", "foo\\\$bar");
     $wfn2->set("product", "insight");
     $wfn2->set("version", "7\\.4\\.0\\.1570");
     $wfn2->set("target_sw", "win2003");
     $wfn2->set("update", new LogicalValue("NA"));
     $wfn2->set("sw_edition", "online");
     $wfn2->set("target_hw", "x64");
     $cpenb = new CPENameBinder();
     echo $cpenb->bindToURI($wfn) . "<br>\n";
     echo $cpenb->bindToFS($wfn2) . "<br>\n";
 }
Ejemplo n.º 3
0
 /**
  * Compares each attribute value pair in two Well Formed Names.
  * @param $source WellFormedName Source WFN
  * @param $target WellFormedName Target WFN
  * @return A array mapping attribute string to attribute value Relation
  */
 public function compareWFNs(WellFormedName $source, WellFormedName $target)
 {
     $result = array();
     $result["part"] = $this->compare($source->get("part"), $target->get("part"));
     $result["vendor"] = $this->compare($source->get("vendor"), $target->get("vendor"));
     $result["product"] = $this->compare($source->get("product"), $target->get("product"));
     $result["version"] = $this->compare($source->get("version"), $target->get("version"));
     $result["update"] = $this->compare($source->get("update"), $target->get("update"));
     $result["edition"] = $this->compare($source->get("edition"), $target->get("edition"));
     $result["language"] = $this->compare($source->get("language"), $target->get("language"));
     $result["sw_edition"] = $this->compare($source->get("sw_edition"), $target->get("sw_edition"));
     $result["target_sw"] = $this->compare($source->get("target_sw"), $target->get("target_sw"));
     $result["target_hw"] = $this->compare($source->get("target_hw"), $target->get("target_hw"));
     $result["other"] = $this->compare($source->get("other"), $target->get("other"));
     return $result;
 }