本文整理汇总了Java中org.nutz.lang.util.NutMap类的典型用法代码示例。如果您正苦于以下问题:Java NutMap类的具体用法?Java NutMap怎么用?Java NutMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NutMap类属于org.nutz.lang.util包,在下文中一共展示了NutMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: checkSign
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
/**
* 校验签名
*
* @param params
* @param key
* @return
*/
public static Boolean checkSign(NutMap params, String key) {
try {
if (Lang.isEmpty(params)) {
throw new Exception("params参数为空");
} else if (Strings.isBlank(key)) {
throw new Exception("key密钥为空");
} else {
if (Strings.equalsIgnoreCase(Lang.md5(Url.encode(buildParmas(params, new String[]{"sign"})) + key), params.getString("sign"))) {
return true;
} else {
return false;
}
}
} catch (Exception e) {
return false;
}
}
开发者ID:howe,项目名称:jdgInf-sdk,代码行数:26,代码来源:JdgUtil.java
示例2: onLineMsg
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
/**
* 上线通知
*/
public void onLineMsg(String name,ChannelContext context){
//直接调用 sendToAll方法会导致错误,不知何种原因
// Aio.sendToAll(context.getGroupContext(), SocketMsgUtils.madeWsResponse(Type.SUCCESS_MESSAGE_RESP,Json.toJson(NutMap.NEW().setv("msg",name+"上线了!"))));
SetWithLock<ChannelContext> allConnectedsChannelContexts = Aio.getAllConnectedsChannelContexts(context.getGroupContext());
Aio.sendToSet(context.getGroupContext(), allConnectedsChannelContexts, SocketMsgUtils.madeWsResponse(Type.SUCCESS_MESSAGE_RESP, Json.toJson(NutMap.NEW().setv("msg", name + "上线了!").setv("count",allConnectedsChannelContexts.getObj().size()))), new ChannelContextFilter() {
@Override
public boolean filter(ChannelContext channelContext) {
if(context == channelContext){
return false;
}else{
return true;
}
}
});
// for (ChannelContext con : allConnectedsChannelContexts.getObj()){
// Aio.sendToSet(context.getGroupContext(), SocketMsgUtils.madeWsResponse(Type.SUCCESS_MESSAGE_RESP,Json.toJson(NutMap.NEW().setv("msg",name+"上线了!"))));
// }
}
开发者ID:TopCoderMyDream,项目名称:LuliChat,代码行数:23,代码来源:Accepter.java
示例3: applyFriend
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
/**
* 申请添加好友
* @param me 我的id
* @param uid 对方id
* @param from_group 到哪个分组?
* @return
*/
@At
public Object applyFriend(@Attr("me") int me,@Param("uid")int uid,@Param("from_group")int from_group ,@Param("remark")String remark){
NutMap nm = new NutMap();
if(!isFirend(me,uid)) {
int i = userDao.applyFriend(uid, me, from_group, remark);
if (1 > 0){
SocketUtils.sendByUserId(String.valueOf(uid), SocketMsgUtils.madeWsResponse(Type.REQFRIEND, "1"));
nm.setv("ok", 1);
}else
nm.setv("ok", 0);
}else{
return Response.fail("对方已经是您的好友,不可重复添加哦!");
}
return nm;
}
开发者ID:TopCoderMyDream,项目名称:LuliChat,代码行数:24,代码来源:UserController.java
示例4: getTemplateShareVars
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
/**
* 模板引擎共用的变量
*/
public static NutMap getTemplateShareVars() {
NutMap share = new NutMap();
Ioc ioc = Mvcs.getIoc();
share.put("ioc", ioc);
PropertiesProxy conf = ioc.get(PropertiesProxy.class, "conf");
share.put("conf", conf.toMap());
if (!conf.getBoolean("cdn.enable", false) || Strings.isBlank(conf.get("cdn.urlbase"))) {
share.put("cdnbase", "");
} else {
share.put("cdnbase", conf.get("cdn.urlbase"));
}
return share;
}
开发者ID:strictnerd,项目名称:windows-file-change,代码行数:19,代码来源:Toolkit.java
示例5: asMap
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
/**
* 根据一个 XML 节点,将其变成一个 Map。
* <p/>
* <b>注意: 不支持混合节点</b>
*
* @param ele
* 元素
* @param lowFirst
* 是否把所有key的首字母都小写
*
* @return 一个 Map 对象
*/
public static NutMap asMap(Element ele, final boolean lowFirst) {
final NutMap map = new NutMap();
eachChildren(ele, new Each<Element>() {
public void invoke(int index, Element _ele, int length)
throws ExitLoop, ContinueLoop, LoopException {
String key = _ele.getNodeName();
if (lowFirst)
key = Strings.lowerFirst(key);
Map<String, Object> tmp = asMap(_ele, lowFirst);
if (!tmp.isEmpty()) {
map.setv(key, tmp);
return;
}
String val = getText(_ele);
if (!Strings.isBlank(val)) {
map.setv(key, val);
}
}
});
return map;
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:34,代码来源:Xmls.java
示例6: resetApikey
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
@At("/ukey/reset")
@GET
@Filters()
public Object resetApikey(@Attr(IotKeys.UID)long userId) {
if (userId == 0)
return Collections.EMPTY_MAP;
IotUser usr = dao.fetch(IotUser.class, userId);
if (usr == null) {
usr = new IotUser();
iotService.makeApiKey(usr);
dao.insert(usr);
} else {
iotService.makeApiKey(usr);
dao.update(usr);
}
return new NutMap().addv("apikey", usr.getApikey());
}
开发者ID:wendal,项目名称:whale,代码行数:18,代码来源:IotAdminModule.java
示例7: render
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
public void render(HttpServletRequest req, HttpServletResponse resp, Object obj) throws Throwable {
String uri = req.getRequestURI();
if (uri.endsWith("/") || uri.endsWith(".")) {
HttpStatusView.HTTP_500.render(req, resp, obj);
return;
}
String reqName = uri.substring(uri.lastIndexOf('/'));
if (!reqName.contains(".")) {
jsonView().render(req, resp, obj);
return;
}
String suffix = reqName.substring(reqName.lastIndexOf('.'));
if ("ajax".equals(suffix)) {
jsonView().render(req, resp, new NutMap().setv("ok", "true").setv("data", obj));
} else if ("xml".equals(suffix)) {
HttpStatusView.HTTP_502.render(req, resp, obj);
} else if ("htm".equals(suffix)) {
new JspView(val).render(req, resp, obj);
} else {
jsonView().render(req, resp, obj);
}
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:23,代码来源:SmartView.java
示例8: resetApikey
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
@At("/iot/apikey/reset")
@GET
@Filters()
public Object resetApikey(@Attr(Zs.UID)long userId) {
if (userId == 0)
return Collections.EMPTY_MAP;
IotUser usr = dao.fetch(IotUser.class, userId);
if (usr == null) {
usr = new IotUser();
iotService.makeApiKey(usr);
dao.insert(usr);
} else {
iotService.makeApiKey(usr);
dao.update(usr);
}
return new NutMap().addv("apikey", usr.getApikey());
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:18,代码来源:IotAdminModule.java
示例9: reflushJsapiTicket
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
protected void reflushJsapiTicket() {
String at = this.getAccessToken();
String url = String.format("%s/ticket/getticket?access_token=%s&type=jsapi", base, at);
if (log.isDebugEnabled())
log.debugf("ATS: reflush jsapi ticket send: %s", url);
Response resp = Http.get(url);
if (!resp.isOK())
throw new IllegalArgumentException("reflushJsapiTicket FAIL , openid=" + openid);
String str = resp.getContent();
if (log.isDebugEnabled())
log.debugf("ATS: reflush jsapi ticket done: %s", str);
NutMap re = Json.fromJson(NutMap.class, str);
String ticket = re.getString("ticket");
int expires = re.getInt("expires_in") - 200;//微信默认超时为7200秒,此处设置稍微短一点
jsapiTicketStore.save(ticket, expires, System.currentTimeMillis());
}
开发者ID:nutzam,项目名称:nutzwx,代码行数:20,代码来源:AbstractWxApi2.java
示例10: reflushAccessToken
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
protected synchronized void reflushAccessToken() {
String url = String.format("%s/token?grant_type=client_credential&appid=%s&secret=%s", base, appid, appsecret);
if (log.isDebugEnabled())
log.debugf("ATS: reflush access_token send: %s", url);
Response resp = Http.get(url);
if (!resp.isOK())
throw new IllegalArgumentException("reflushAccessToken FAIL , openid=" + openid);
String str = resp.getContent();
if (log.isDebugEnabled())
log.debugf("ATS: reflush access_token done: %s", str);
NutMap re = Json.fromJson(NutMap.class, str);
String token = re.getString("access_token");
int expires = re.getInt("expires_in") - 200;//微信默认超时为7200秒,此处设置稍微短一点
accessTokenStore.save(token, expires, System.currentTimeMillis());
}
开发者ID:nutzam,项目名称:nutzwx,代码行数:19,代码来源:AbstractWxApi2.java
示例11: genJsSDKConfig
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
@Override
public NutMap genJsSDKConfig(String url, String... jsApiList) {
String jt = this.getJsapiTicket();
long timestamp = System.currentTimeMillis();
String nonceStr = R.UU64();
String str = String.format("jsapi_ticket=%s&noncestr=%s×tamp=%d&url=%s", jt, nonceStr, timestamp, url);
String signature = Lang.sha1(str);
NutMap map = new NutMap();
map.put("appId", appid);
map.put("timestamp", timestamp);
map.put("nonceStr", nonceStr);
map.put("signature", signature);
map.put("jsApiList", jsApiList);
return map;
}
开发者ID:nutzam,项目名称:nutzwx,代码行数:18,代码来源:AbstractWxApi2.java
示例12: postPay
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
/**
* 微信支付公共POST方法(带证书)
*
* @param url 请求路径
* @param key 商户KEY
* @param params 参数
* @param file 证书文件
* @param password 证书密码
* @return
*/
@Override
public NutMap postPay(String url, String key, Map<String, Object> params, File file, String password) {
params.remove("sign");
String sign = WxPaySign.createSign(key, params);
params.put("sign", sign);
Request req = Request.create(url, METHOD.POST);
req.setData(Xmls.mapToXml(params));
Sender sender = Sender.create(req);
SSLSocketFactory sslSocketFactory;
try {
sslSocketFactory = WxPaySSL.buildSSL(file, password);
} catch (Exception e) {
throw Lang.wrapThrow(e);
}
sender.setSSLSocketFactory(sslSocketFactory);
Response resp = sender.send();
if (!resp.isOK())
throw new IllegalStateException("postPay with SSL, resp code=" + resp.getStatus());
return Xmls.xmlToMap(resp.getContent("UTF-8"));
}
开发者ID:nutzam,项目名称:nutzwx,代码行数:31,代码来源:WxApi2Impl.java
示例13: genTagPages
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void genTagPages(Rendering ing) {
if (!Strings.isBlank(tagPath)) {
log.infof("make tags >> %s/*", tagPath);
// 得到文档模板对象
ZDocRule rule = getRule(tagPath);
if (null == rule) {
log.warnf("No rule for '%s' when genTagPages", tagPath);
return;
}
ZDocTemplate tmpl = ing.tfa().getTemplte(rule.key());
NutMap page = new NutMap();
page.setv("bpath", "../");
ing.context().setv("page", page);
Map<String, ZDocTag> tags = ing.context().getAs("tags", Map.class);
for (ZDocTag tag : tags.values()) {
_gen_tag_page(ing, tmpl, page, tag);
}
// 生成 others Tag
_gen_tag_page(ing, tmpl, page, othersTag);
} else {
log.info("! Ignore tags");
}
}
开发者ID:zozoh,项目名称:zdoc,代码行数:26,代码来源:RenderToHtml.java
示例14: _gen_tag_page
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
private void _gen_tag_page(Rendering ing,
ZDocTemplate tmpl,
NutMap page,
ZDocTag tag) {
page.setv("title", tag.getText());
ing.context().setv("tag", tag.genItems());
// 在目标目录创建对应文件
ZFile destf = dest.createFileIfNoExists(tagPath
+ "/"
+ tag.getKey()
+ ".html");
// 准备渲染
Writer wr = Streams.utf8w(ing.io().openOutputStream(destf));
tmpl.outputTo(wr, ing.context());
Streams.safeClose(wr);
}
开发者ID:zozoh,项目名称:zdoc,代码行数:18,代码来源:RenderToHtml.java
示例15: test_view_render
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
public void test_view_render() throws Throwable {
// 存入模板
loader.put("/hello", "${obj.array.~size},${obj.array[0]},${json(obj.user)}");
// 创建视图
View view = maker.make(null, "beetl", "/hello");
// 准备好返回值
Map<String, Object> map = new HashMap<String, Object>();
map.put("array", new String[]{"http://wendal.net"});
map.put("user", new NutMap().setv("name", "wendal"));
// 用于接收视图渲染的结果
ByteArrayOutputStream out = new ByteArrayOutputStream();
// mock出req和resp
HttpServletRequest req = mockReq(map);
HttpServletResponse resp = mockResp(out);
// 渲染
view.render(req, resp, map);
// 对比结果
assertEquals("1,http://wendal.net,{\"name\":\"wendal\"}", new String(out.toByteArray()));
}
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:26,代码来源:BeetlViewMakerTest.java
示例16: getSign
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
/**
* 生成签名
*
* @param map 加密对象
* @param key 密钥
* @return
*/
public static String getSign(NutMap map, String key) {
try {
if (Lang.isEmpty(map)) {
throw new Exception("map为空");
} else if (Strings.isEmpty(key)) {
throw new Exception("key为空");
} else {
return Lang.md5(JdgUtil.buildParmas(map, new String[]{"sign"}) + key);
}
} catch (Exception e) {
return null;
}
}
开发者ID:howe,项目名称:jdgInf-sdk,代码行数:22,代码来源:JdgUtil.java
示例17: sendPrivateMsg
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
@Override
public CqpHttpApiResp sendPrivateMsg(long qq, String message) {
NutMap nutMap = new NutMap("action", SEND_PRIVATE_MSG)
.setv("params", new NutMap("user_id", qq)
.setv("message", message)
);
sendMsg(JsonUtils.toJson(nutMap));
return null;
}
开发者ID:yangjinhe,项目名称:maintain-robot,代码行数:10,代码来源:CqpWebsocketApi.java
示例18: sendGroupMsg
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
@Override
public CqpHttpApiResp sendGroupMsg(long groupId, String message) {
NutMap nutMap = new NutMap("action", SEND_GROUP_MSG)
.setv("params", new NutMap("group_id", groupId)
.setv("message", message)
);
sendMsg(JsonUtils.toJson(nutMap));
return null;
}
开发者ID:yangjinhe,项目名称:maintain-robot,代码行数:10,代码来源:CqpWebsocketApi.java
示例19: sendDisCussMsg
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
@Override
public CqpHttpApiResp sendDisCussMsg(long groupId, String message) {
NutMap nutMap = new NutMap("action", SEND_DISCUSS_MSG)
.setv("params", new NutMap("discuss_id", groupId)
.setv("message", message)
);
sendMsg(JsonUtils.toJson(nutMap));
return null;
}
开发者ID:yangjinhe,项目名称:maintain-robot,代码行数:10,代码来源:CqpWebsocketApi.java
示例20: offLineMsg
import org.nutz.lang.util.NutMap; //导入依赖的package包/类
public void offLineMsg(String name,ChannelContext context){
SetWithLock<ChannelContext> allConnectedsChannelContexts = Aio.getAllConnectedsChannelContexts(context.getGroupContext());
Aio.sendToSet(context.getGroupContext(), allConnectedsChannelContexts, SocketMsgUtils.madeWsResponse(Type.FAIL_MESSAGE_RESP, Json.toJson(NutMap.NEW().setv("msg", name + "下线了!").setv("count",allConnectedsChannelContexts.getObj().size()))), new ChannelContextFilter() {
@Override
public boolean filter(ChannelContext channelContext) {
if(context == channelContext){
return false;
}else{
return true;
}
}
});
}
开发者ID:TopCoderMyDream,项目名称:LuliChat,代码行数:14,代码来源:Accepter.java
注:本文中的org.nutz.lang.util.NutMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论