本文整理汇总了Java中net.jini.core.entry.Entry.getClass方法的典型用法代码示例。如果您正苦于以下问题:Java Entry.getClass方法的具体用法?Java Entry.getClass怎么用?Java Entry.getClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.jini.core.entry.Entry
的用法示例。
在下文中一共展示了Entry.getClass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cloneEntry
import net.jini.core.entry.Entry; //导入方法依赖的package包/类
private Entry cloneEntry(Entry attr) {
try {
Class realClass = attr.getClass();
Entry template = (Entry) realClass.newInstance();
Field[] f = realClass.getFields();
for(int i = 0; i < f.length; i++) {
if(! usableField(f[i]))
continue;
f[i].set(template, f[i].get(attr));
}
return template;
} catch (Throwable t) {
logger.log(Level.INFO, "duplicating entry failed", t);
}
return null;
}
示例2: getFieldValueSet
import net.jini.core.entry.Entry; //导入方法依赖的package包/类
private HashSet getFieldValueSet(Entry entry, String fieldName) {
// use providers attributes
HashSet vset = new HashSet();
Class type = entry.getClass();
for (int i = 0; i < attributes.length; i++) {
try {
Field field = attributes[i].getClass().getField(fieldName);
Object value = field.get(attributes[i]);
if (value != null) {
vset.add(value);
}
} catch (Exception e) {
// ignore
}
}
return vset;
}
示例3: generateTemplate
import net.jini.core.entry.Entry; //导入方法依赖的package包/类
private Entry generateTemplate(Entry attr) {
try {
Class realClass = attr.getClass();
Entry template = (Entry) realClass.newInstance();
Field[] f = realClass.getFields();
for(int i = 0; i < f.length; i++)
f[i].set(template, null);
return template;
} catch (Throwable t) {
logger.log(Level.INFO, "instantiating template failed", t);
}
return null;
}
示例4: doUpdates
import net.jini.core.entry.Entry; //导入方法依赖的package包/类
/**
* Request all the args currently in the space.
*
* @throws TransactionException
* ,RemoteException,UnusableEntryException
*/
private void doUpdates() throws TransactionException,
UnusableEntryException, RemoteException {
if (firstTime) {
firstTime = false;
JTable table = new JTable(entryCountTableModel);
JScrollPane scrollPane = new JScrollPane(table);
remove(introView);
add(scrollPane, BorderLayout.CENTER);
invalidate();
getParent().validate();
addMouseListener(table);
}
// here we're asking for all the args in the space
// you could modify this sample GUI to allow user input of an entry
// class name
AdminIterator iter = javaSpaceAdmin.contents(null/* Entry template */,
null/* Transaction */);
List list = new ArrayList();
Map entryMap = new HashMap();
int ueCount = 0;
int got = 0;
while (true) {
try {
Entry e = iter.next();
if (e == null)/* || got>=maxEntries) */{
break;
}
got++;
Class entryClass = e.getClass();
String entryClassName = entryClass.getName();
Object[] data = (Object[]) entryMap.get(entryClassName);
if (data == null) {
Object template = null;
try {
template = entryClass.newInstance();
} catch (Exception ex) {
System.out.println(ex);
}
entryMap.put(entryClassName, new Object[] { entryClassName,
new Integer(1), template });
} else {
Integer count = (Integer) data[1];
data[1] = new Integer(count.intValue() + 1);
}
} catch (UnusableEntryException uee) {
// add as UnusableEnrty
uee.printStackTrace();
ueCount++;
// throw uee;
}
}
iter.close();
System.out.println("Outrigger viewer retreived " + got + " args");
if (ueCount > 0) {
entryMap.put(UNUSABLE_ENTRY, new Object[] { UNUSABLE_ENTRY,
new Integer(ueCount), null });
}
// get the object counts
Collection col = entryMap.values();
List counterList = new ArrayList();
counterList.addAll(col);
entryCountTableModel.update(counterList);
}