重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

获取群成员java代码 java抓取微信群聊天记录

Java反射机制获取内部类的静态成员

最近需要些一个可配置的索引构建程序 需要在运行时调用Lucene包的如下类及其成员

成都创新互联公司-云计算及IDC服务提供商,涵盖公有云、IDC机房租用、四川乐山服务器托管、等保安全、私有云建设等企业级互联网基础服务,咨询热线:18982081108

引用

Nested Class Summary

static class Field Index

Specifies whether and how a field should be indexed

static class Field Store

Specifies whether and how a field should be stored

static class Field TermVector

Specifies whether and how a field should have term vectors

lucene api中称之为Nested Class 意为嵌套类 而嵌套类内部的File Index的成员又是静态成员

引用

Field Summary

static Field Index ANALYZED

Index the tokens produced by running the field s value through an Analyzer

static Field Index ANALYZED_NO_NORMS

Expert: Index the tokens produced by running the field s value through an Analyzer and also separately disable the storing of norms

static Field Index NO

Do not index the field value

static Field Index NO_NORMS

Deprecated This has been renamed to NOT_ANALYZED_NO_NORMS

static Field Index NOT_ANALYZED

Index the field s value without using an Analyzer so it can be searched

static Field Index NOT_ANALYZED_NO_NORMS

Expert: Index the field s value without an Analyzer and also disable the storing of norms

static Field Index TOKENIZED

Deprecated this has been renamed to ANALYZED

static Field Index UN_TOKENIZED

Deprecated This has been renamed to NOT_ANALYZED

一个棘手的问题 如果获得这些内部静态成员?

最后采用了如下方法

//运行时调用Filed Index类型

Java代码

Class? cls = apache lucene document Field Index class;

java lang reflect Field indexDeclareField = cls getDeclaredField(field getIndex());

Object indexDeclareFieldType = indexDeclareField get(cls);

apache lucene document Field Index filedIndex = ( apache lucene document Field Index)indexDeclareFieldType;

//运行时调用Field Store类型

Class? clsStore = apache lucene document Field Index class;

java lang reflect Field storeDeclareField = cls getDeclaredField(field getIndex());

Object indexStoreDeclareField = indexDeclareField get(cls);

lishixinzhi/Article/program/Java/hx/201311/26078

IM项目中群成员获取与缓存策略

在IM项目(Android)中,我们需要获取群成员,往往数据较大,获取缓慢,所以需要做个缓存,提升用户体验。

缓存:

定义成员集合接口:

定义缓存器接口:

获取:

先判断缓存,再递归获取全部群成员。

注 :lruCache 计算size,不能用成员个数(即 list.size() )来计算,因为一个群的成员在存入后中途是大小会发生变化,会导致lruCache内部维护的size计算小于0 , trimToSize 方法 抛出IllegalStateException 异常。

java 模拟登录后,获取服务器上对应的cookie值

登陆验证成功后存入session,想要获取的话掉通过session获取

session.put(key, value);

object object = session.get(key);

用户信息一般放在session里面


新闻标题:获取群成员java代码 java抓取微信群聊天记录
链接分享:http://cqcxhl.cn/article/ddjipei.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP