コード例 #1
0
ファイル: InMemoryStorage.php プロジェクト: cubiche/cubiche
 /**
  * {@inheritdoc}
  */
 public function get($key, $default = null)
 {
     $this->validateKey($key);
     if (!$this->store->containsKey($key)) {
         return $default;
     }
     return $this->serializer->deserialize($this->store->get($key));
 }
コード例 #2
0
ファイル: HashMapTest.php プロジェクト: robo47/BlazeFramework
 public function testPutAll()
 {
     // Remove the following lines when you implement this test.
     $hashmap = new HashMap();
     $hashmap->put(87, 48);
     $hashmap->put(45, 98);
     $hashmap->put(7889, 4);
     $this->object->putAll($hashmap);
     $this->assertTrue($this->object->get(87)->toNative() == 48);
     $this->assertTrue($this->object->containsValue(48));
     $this->assertTrue($this->object->get(45)->toNative() == 98);
     $this->assertTrue($this->object->containsValue(98));
     $this->assertTrue($this->object->get(7889)->toNative() == 4);
     $this->assertTrue($this->object->containsValue(4));
 }
コード例 #3
0
 function testPutSameElementTwice()
 {
     $map = new HashMap("integer", "string");
     $map->put(4, "Peter");
     $map->put(4, "Raf");
     $this->assertEqual(1, $map->size());
     $this->assertEqual("Raf", $map->get(4));
 }
コード例 #4
0
ファイル: HashMapTest.php プロジェクト: trashtoy/peach2
 /**
  * コンストラクタをテストします. 以下を確認します.
  * 
  * - 引数を指定しない場合は空の HashMap が生成されること
  * - 引数に配列を指定した場合, その配列のキーと値をマッピングした HashMap が生成されること
  * - 引数に Map を指定した場合, その Map と同じマッピングの HashMap が生成されること
  * - 第 3 引数に 2 より少ない整数を指定した場合は 2 として扱われること
  */
 public function test__construct()
 {
     $map1 = new HashMap();
     $this->assertSame(0, $map1->size());
     $arr = array("first" => 1, "second" => 2, "third" => 3);
     $map2 = new HashMap($arr);
     $this->assertSame(3, $map2->size());
     $this->assertSame(1, $map2->get("first"));
     $map3 = new HashMap($map2);
     $this->assertSame(3, $map3->size());
     $map3->put("second", 20);
     $this->assertSame(20, $map3->get("second"));
     $this->assertSame(2, $map2->get("second"));
     $map4 = new HashMap(null, null, 2);
     $map5 = new HashMap(null, null, -1);
     $this->assertEquals($map4, $map5);
 }
コード例 #5
0
 public static function restSubscribe()
 {
     self::initRequests();
     if (strpos(self::link(), "?") !== false) {
         $link = substr(self::link(), 0, strpos(self::link(), "?"));
     } else {
         $link = self::link();
     }
     if (!Session::isLogged()) {
         if (self::$map_requests->containsKey($link)) {
             if (file_exists(self::$map_requests->get($link))) {
                 return self::$map_requests->get($link);
             }
             throw new FileNotFoundException("Arquivo de requisição não encontrado!");
         }
         throw new Exception("Destino não encontrado!");
     } else {
         throw new LoginException('Você não pode realizar seu cadastro com um usuário online.');
     }
 }
コード例 #6
0
 /**
  * @return HashMap
  */
 public function getCotacoes()
 {
     $map = new CodeMap();
     $values = new HashMap();
     $values->put("BMF", new ArrayIterator());
     $values->put("London", new ArrayIterator());
     $values->put("NY", new ArrayIterator());
     $values->put("Dolar", new ArrayIterator());
     $values->put("Euro", new ArrayIterator());
     $values->put("Arabica", new ArrayIterator());
     $values->put("IBovespa", new ArrayIterator());
     $dateMap = new DateMap();
     $classifier = new Classifier($dateMap);
     foreach ($this->json as $cotacao) {
         $cotation = $classifier->classify($cotacao);
         if ($cotation != null) {
             $cotation->setJsonInfo($cotacao);
             $values->get($cotation->type())->append($cotation);
         }
         $cot = new Cotacao();
     }
     return $values;
 }
コード例 #7
0
ファイル: HashMapEntryTest.php プロジェクト: trashtoy/peach2
 /**
  * HashMapEntry に対する操作が, HashMap に適用されていることを確認します.
  * 
  * @covers Peach\Util\HashMapEntry::setValue
  */
 public function testSetValue()
 {
     $entry = $this->object;
     $entry->setValue(100);
     $this->assertSame(100, $this->map->get("First"));
 }
コード例 #8
0
ファイル: refundNotify_2.php プロジェクト: icevisual/notes
//否则当平台通知数据发生变化时,容易出现接收数据验签不通过情况)
$data = new HashMap();
$data->put("mer_date", $_REQUEST['mer_date']);
if ($_REQUEST['error_code'] != null) {
    $data->put("error_code", $_REQUEST['error_code']);
}
$data->put("mer_id", $_REQUEST['mer_id']);
$data->put("order_id", $_REQUEST['order_id']);
$data->put("refund_amt", $_REQUEST['refund_amt']);
$data->put("refund_no", $_REQUEST['refund_no']);
$data->put("refund_state", $_REQUEST['refund_state']);
$data->put("version", $_REQUEST['version']);
$data->put("sign", $_REQUEST['sign']);
$data->put("sign_type", $_REQUEST['sign_type']);
//获取请求数据
$error_code = $data->get("error_code");
$mer_date = $data->get("mer_date");
$mer_id = $data->get("mer_id");
$order_id = $data->get("order_id");
$refund_amt = $data->get("refund_amt");
$refund_no = $data->get("refund_no");
$refund_state = $data->get("refund_state");
$version = $data->get("version");
$sign = $data->get("sign");
$sign_type = $data->get("sign_type");
//获取UMPAY平台请求商户的退款结果通知数据,并对请求数据进行验签,此时商户接收到的退款结果通知会存放在这里,商户可以根据此处的trade_state订单状态来更新订单
$resData = new HashMap();
try {
    //获取UMPAY平台请求商户的退款结果通知数据,并对请求数据进行验签
    //如验证平台签名正确,即应响应UMPAY平台返回码为0000。【响应返回码代表通知是否成功,和通知的退款结果】
    //验签支付结果通知 如验签成功,则返回ret_code=0000
コード例 #9
0
 function testUndefinedOffset()
 {
     $map = new HashMap("integer", "string");
     $this->assertNull($map->get(45));
 }
コード例 #10
0
 $round;
 for ($round = 1; $tempmax > 0.2 && $round < $fnum - $fnum / 20; $round++) {
     $tempmax = -1000;
     for ($f1 = 0; $f1 < $fnum; $f1++) {
         for ($f2 = 0; $f2 < $fnum; $f2++) {
             if ($cosmatrix[$f1][$f2] > $tempmax && $f1 != $f2 && $I[$f1] == 1 && $I[$f2] == 1) {
                 //      echo "YA";
                 $tempmax = $cosmatrix[$f1][$f2];
                 $maxf1 = $f1;
                 $maxf2 = $f2;
             }
         }
     }
     //end search
     // echo "MAX1:$maxf1</br>";echo "MAX2:$maxf2</br>";
     $c1 = $cluster->get($maxf1);
     $c2 = $cluster->get($maxf2);
     $c3 = array_merge($c1, $c2);
     asort($c3);
     $cluster->remove($maxf1);
     $cluster->remove($maxf2);
     $cluster->put($maxf1, $c3);
     $len1 = pow(count($HFlist->get($flist[$maxf1])), 0.5) + 1.0E-8;
     $len2 = pow(count($HFlist->get($flist[$maxf2])), 0.5) + 1.0E-8;
     for ($i = 0; $i < $fnum; $i++) {
         $cosmatrix[$maxf1][$i] = ($len1 * $cosmatrix[$maxf1][$i] + $len2 * $cosmatrix[$maxf2][$i]) / ($len1 + $len2);
         $cosmatrix[$i][$maxf1] = $cosmatrix[$maxf1][$i];
     }
     $I[$maxf2] = 0;
 }
 //end round for*/
コード例 #11
0
ファイル: common.php プロジェクト: icevisual/notes
 /**
  * getPlainSortAndByAnd方法 使用&符号组织签名明文串排序a-z,如:merId=9996&goodsId=100&version=3.0
  * @param HashMap $map
  */
 public static function getPlainSortAndByAnd($map)
 {
     $log = new Logger();
     $plain = "";
     $arg = "";
     $paramter = array();
     if (!$map->isEmpty() && $map->size() > 0) {
         $keys = $map->keys();
         foreach ($keys as $key) {
             // $log->logInfo (" ssssssgetRequestData plain111122333=" . $keys );
             //如果是sign_type 不许要参与RAS签名
             if ("sign_type" != $key) {
                 $plain = $plain . $key . "=" . $map->get($key) . "|";
                 //$paramter = explode ( "&", $plain );
                 $paramter[$key . "=" . $map->get($key)] = $key . "=" . $map->get($key);
             }
         }
         $plain = substr($plain, 0, strlen($plain) - 1);
         // 			$log->logInfo (" ssssssgetRequestData plain111122=" . $plain );
         //$paramter = explode ( "|", $plain );
         $sort_array = StringUtil::arg_sort($paramter);
         //得到从字母a到z排序后的加密参数数组
         while (list($key, $val) = each($sort_array)) {
             $arg .= $val . "&";
             //$log->logInfo (" ssssssgetRequestData plain11=" . $arg );
         }
         $arg = substr($arg, 0, count($arg) - 2);
         //去掉最后一个&字符
         //die ( "使用&组织签名明文串失败:传入参数为空!".$arg."|".plain );
         return $arg;
     } else {
         die("Use & organize signature plaintext string failure: incoming parameters is empty!");
         return null;
     }
     //$log->logInfo (" ssssssgetRequestData plain115=" . $arg );
     return $arg;
 }
コード例 #12
0
ファイル: HashMapTest.php プロジェクト: RadekDvorak/Ardent
 /**
  * @depends testOffsetSetOffsetGet
  */
 function testHashNull()
 {
     $map = new HashMap();
     $map->set(null, 1);
     $this->assertEquals(1, $map->get(null));
 }
コード例 #13
0
 public function getOthersForDestiny()
 {
     return $this->map2->get("Outros");
 }
コード例 #14
0
ファイル: mer2PlatUtil.php プロジェクト: icevisual/notes
 /**
  * 4.0接口商户响应平台分账请求结果通知(商户到平台,直连网银)检查数据字段合法性并生成签名明文串
  * @param HashMap $map
  * @return 签名明文串,使用&符号组织签名明文串,如:mer_id=9996&amount=100
  */
 public static function getSplitRequestNotifyResDataPlain($map)
 {
     $data = new HashMap();
     $mer_id = StringUtil::trim($map->get("mer_id"));
     if ("" == $mer_id || strlen($mer_id) > 8) {
         die("mer_id为空或者长度超过限制");
     }
     $order_id = StringUtil::trim($map->get("order_id"));
     if ("" == $order_id || strlen($order_id) > 32) {
         die("order_id为空或者长度超过限制");
     }
     $mer_date = StringUtil::trim($map->get("mer_date"));
     if (!DateUtil::checkData($mer_date)) {
         die("mer_date为空或者长度不符合要求");
     }
     $ret_code = StringUtil::trim($map->get("ret_code"));
     if ("" == $ret_code || strlen($ret_code) != 4) {
         die("ret_code为空或者长度不符合要求");
     }
     $sign_type = StringUtil::trim($map->get("sign_type"));
     if ("" == $sign_type || strlen($sign_type) > 8) {
         die("sign_type为空或者长度不符合要求");
     }
     $version = StringUtil::trim($map->get("version"));
     if ("" == $version || strlen($version) != 3) {
         die("version为空或者长度不符合要求");
     }
     if (!is_null($map->get("ret_msg"))) {
         $ret_msg = StringUtil::trim($map->get("ret_msg"));
         if (strlen($ret_msg) > 128) {
             die("ret_msg长度不符合要求");
         }
         $data->put("ret_msg", $ret_msg);
     }
     $data->put("mer_id", $mer_id);
     $data->put("order_id", $order_id);
     $data->put("mer_date", $mer_date);
     $data->put("ret_code", $ret_code);
     $data->put("sign_type", $sign_type);
     $data->put("version", $version);
     return StringUtil::getPlainSortAndByAnd($map);
 }
コード例 #15
0
 /**
  * @covers            HashMap::get
  * @expectedException OutOfBoundsException
  */
 public function testExceptionIsRaisedWhenAccessingAnElementThatDoesNotExist()
 {
     $store = new HashMap();
     $store->get('foo');
 }
コード例 #16
0
 /**
  *
  * @param SerializationStreamWriter $streamWriter
  * @param HashMap $instance
  * @param MappedClass $instanceClass
  * @throws SerializationException
  */
 public static function serialize(SerializationStreamWriter $streamWriter, $instance, MappedClass $instanceClass)
 {
     if ($instance instanceof HashMap) {
         $size = $instance->size();
         $streamWriter->writeInt($size);
         //assert($instanceClass->isGeneric()); //jesli nie array to zapomniano w gwtphpmap dodacgenericsow
         if ($instanceClass->isGeneric()) {
             $typeParameters = $instanceClass->getTypeParameters();
         } else {
             $typeParameters = array();
         }
         assert(is_array($typeParameters));
         //jesli nie array to zapomniano w gwtphpmap dodacgenericsow
         foreach ($instance->getKeySet() as $key) {
             $streamWriter->writeObject($key, $typeParameters[0]);
             $streamWriter->writeObject($instance->get($key), $typeParameters[1]);
         }
     } else {
         if (is_array($instance)) {
             // $instance is array
             //$size = $instance->size();
             $size = count($instance);
             $streamWriter->writeInt($size);
             //for (Object obj : instance) {
             if (!$instanceClass->isGeneric()) {
                 require_once GWTPHP_DIR . '/maps/java/lang/SerializationException.class.php';
                 throw new SerializationException("Error occurred while casting native php array to HashMap: " . "HashMap must be mapped as generic type! add < > to signatures and CRC");
             }
             $typeParameters = $instanceClass->getTypeParameters();
             if (!isset(HashMap_CustomFieldSerializer::$ACCEPTABLE_KEY_TYPES[$typeParameters[0]->getSignature()])) {
                 require_once GWTPHP_DIR . '/maps/java/lang/SerializationException.class.php';
                 throw new SerializationException("Error occurred while casting native php array to HashMap: " . "HashMap_CustomFieldSerializer serialize only array() where " . "keys object are mapped by one of following types: " . "java.lang.String, java.lang.Byte, java.lang.Character, java.lang.Double, " . "java.lang.Float, java.lang.Integer, java.lang.Long, java.lang.Short, but given: " . $typeParameters[0]->getSignature());
             }
             foreach ($instance as $key => $obj) {
                 $streamWriter->writeObject($key, $typeParameters[0]);
                 $streamWriter->writeObject($obj, $typeParameters[1]);
             }
         } else {
             require_once GWTPHP_DIR . '/maps/java/lang/UnimplementedOperationException.class.php';
             throw new UnimplementedOperationException("HashMap_CustomFieldSerializer serialize type: " + gettype($instance) + " not implemented");
         }
     }
 }
コード例 #17
0
ファイル: merNotify_3.php プロジェクト: icevisual/notes
if ($_REQUEST['card_holder'] != null) {
    $data->put("card_holder", $_REQUEST['card_holder']);
}
if ($_REQUEST['last_four_cardid'] != null) {
    $data->put("last_four_cardid", $_REQUEST['last_four_cardid']);
}
if ($_REQUEST['usr_busi_agreement_id'] != null) {
    $data->put("usr_busi_agreement_id", $_REQUEST['usr_busi_agreement_id']);
}
if ($_REQUEST['usr_pay_agreement_id'] != null) {
    $data->put("usr_pay_agreement_id", $_REQUEST['usr_pay_agreement_id']);
}
$data->put("version", $_REQUEST['version']);
$data->put("sign", $_REQUEST['sign']);
//获取请求数据
$service = $data->get("service");
$charset = $data->get("charset");
$mer_id = $data->get("mer_id");
$sign_type = $data->get("sign_type");
$order_id = $data->get("order_id");
$mer_date = $data->get("mer_date");
$trade_no = $data->get("trade_no");
$goods_id = $data->get("goods_id");
$pay_date = $data->get("pay_date");
$amount = $data->get("amount");
$amt_type = $data->get("amt_type");
$pay_type = $data->get("pay_type");
$media_id = $data->get("media_id");
$media_type = $data->get("media_type");
$settle_date = $data->get("settle_date");
$mer_priv = $data->get("mer_priv");
コード例 #18
0
 /**
  * This method tests the merge method
  * of the hash map.
  *
  * @return void
  */
 public function testMerge()
 {
     // initialize a new HashMap
     $map = new HashMap();
     // initialize a new hash map and add some elements
     $mergeMap = new HashMap();
     $mergeMap->add(1, "test_merge_1");
     $mergeMap->add(3, "test_merge_3");
     // add some elements to the original hash map
     $map->add(1, "test_original_1");
     $map->add(2, "test_original_2");
     // merge the original map with the new one
     $map->merge($mergeMap);
     // check the merge result
     $this->assertEquals(3, $map->size());
     $this->assertEquals("test_original_1", $map->get(1));
 }