本文整理汇总了Java中com.mongodb.BasicDBList.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java BasicDBList.toArray方法的具体用法?Java BasicDBList.toArray怎么用?Java BasicDBList.toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mongodb.BasicDBList
的用法示例。
在下文中一共展示了BasicDBList.toArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toAgentCfgDbObject
import com.mongodb.BasicDBList; //导入方法依赖的package包/类
private AgentConfigurationDatabase toAgentCfgDbObject(DBObject dbObject) {
AgentConfigurationDatabase agentCfgDb = new AgentConfigurationDatabase();
agentCfgDb.setAgentId((String) dbObject.get("agentId"));
DBObject agentCfgDbObj = (DBObject) dbObject.get("agentConfiguration");
AgentConfiguration ac = new AgentConfiguration();
ac.setExec((String) agentCfgDbObj.get("exec"));
ac.setComponent((String) agentCfgDbObj.get("component"));
AgentConfigurationPacketbeat packetbeat = new AgentConfigurationPacketbeat();
packetbeat.setStream((String) ((DBObject)agentCfgDbObj.get("packetbeat")).get("stream"));
ac.setPacketbeat(packetbeat);
AgentConfigurationTopbeat topbeat = new AgentConfigurationTopbeat();
topbeat.setStream((String) ((DBObject)agentCfgDbObj.get("topbeat")).get("stream"));
ac.setTopbeat(topbeat);
AgentConfigurationFilebeat filebeat = new AgentConfigurationFilebeat();
filebeat.setStream((String) ((DBObject)agentCfgDbObj.get("filebeat")).get("stream"));
BasicDBList paths = (BasicDBList) ((DBObject)agentCfgDbObj.get("filebeat")).get("paths");
String[] pathsArr = paths.toArray(new String[0]);
List<String> pathsList = new ArrayList<String>();
for(String path : pathsArr) {
// add to the list
pathsList.add(path);
}
filebeat.setPaths(pathsList);
ac.setFilebeat(filebeat);
agentCfgDb.setAgentConfiguration(ac);
return agentCfgDb;
}
示例2: convertBasicDBListToObjectArray
import com.mongodb.BasicDBList; //导入方法依赖的package包/类
/**
* Converts a {@link BasicDBList} into an array of {@link Object}s.
* @param basicDbList the {@link BasicDBList} to convert.
* @return the array of {@link Object}s.
*/
public static Object[] convertBasicDBListToObjectArray(final BasicDBList basicDbList) {
final List<Object> list = new ArrayList<>();
final Object[] array = basicDbList.toArray();
for (final Object child : array) {
if (child instanceof BasicDBList) {
list.add(convertBasicDBListToObjectArray((BasicDBList)child));
} else {
list.add(child);
}
}
return list.toArray(new Object[0]);
}