我有一个场景,我需要从Web服务API获取500并将最终输出值显示为逗号分隔值,如id,name,owner,account,path,ccvalues。为了实现这一点,我正在编写一个方法,我可以获取所有这些信息并设置为一个java对象。字段在下面。最后,我创建了一个包含此Video对象的列表。 videos.add(视频)
String identifier;
String name;
String ownerName;
String accountName;
String mediaPath;
List<KalturaLanguage> ccList;
现在如何显示视频列表对象的输出。请帮我解决这个问题。
代码是:
for (String mediaId : mediaList) {
if (mediaId != null) {
String mediaFullPath = getMediaPath(mediaId);
entryInfo = getMedia(mediaId);
metadataList = getMetadata(mediaId);
ccs = getClosedCaptions(mediaId);
if (entryInfo != null) {
video = new Video();
System.out.println("entryInfo.id"
+ entryInfo.id);
System.out.println("entryInfo.name"
+ entryInfo.name);
System.out.println("mediaFullPath"
+ mediaFullPath);
video.setIdentifier(entryInfo.id);
video.setName(entryInfo.name);
video.setMediaPath(mediaFullPath);
}
if (metadataList != null
&& metadataList.totalCount != 0) {
List<KalturaMetadata> metadataObjs = metadataList.objects;
if (metadataObjs != null
&& metadataObjs.size() > 0) {
for (int i = 0; i < metadataObjs.size(); i++) {
KalturaMetadata metadata = metadataObjs
.get(i);
if (metadata != null) {
if (metadata.xml != null) {
metadataValues = parseXml(metadata.xml);
if (metadataValues.size() != 0) {
ibmAccountList = metadataValues
.get(0);
for (String account : ibmAccountList) {
System.out
.println("IBM Account Name ------->"
+ account);
video.setAccountName(account);
}
ownerList = metadataValues
.get(1);
for (String owner : ownerList) {
System.out
.println("Account Owner Name ------->"
+ owner);
video.setOwnerName(owner);
}
}
}
}
}
}
}
}
if (ccs.size() != 0) {
for (Map.Entry<String, List<KalturaCaptionAsset>> entry : ccs
.entrySet()) {
String key = entry.getKey();
List<KalturaCaptionAsset> values = entry
.getValue();
// System.out.println("Key = " + key);
for (KalturaCaptionAsset asset : values) {
System.out.println(" CC value : "
+ asset.language);
ccList.add(asset.language);
video.setCcList(ccList);
videos.add(video);
}
}
}
}
答案 0 :(得分:3)
你走错了方向。只需在(function($) {
//your model
var urls = {
isuzu: "https://www.direct4x4.co.uk/catalog/category/view/s/d-max-2012-onwards-canopies-hard-tops-accessories/id/17174/*_blank",
ford: "https://www.direct4x4.co.uk/catalog/category/view/s/ranger-t6-2012-canopies-hard-tops-onwards/id/17175/*_blank",
nissan: "",
mitsubishi: "",
toyota: "",
vw: "",
}
//updating the currentUrl
var currentUrl = "";
$("#select").on("change", function(e) {
var val = $("#select").find('option:selected').attr("value");
currentUrl = urls[val];
});
$("#myForm").on("submit", function(e) {
e.preventDefault();
console.log(currentUrl);
window.open(currentUrl);
});
}(jQuery));
类中实施toString
方法。
当您遍历列表并打印视频对象时,它会在视频类中调用Video
方法。
在视频类中提供实现时,生成所需格式的字符串。