本文整理汇总了Java中org.apache.commons.lang.ArrayUtils.removeElement方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtils.removeElement方法的具体用法?Java ArrayUtils.removeElement怎么用?Java ArrayUtils.removeElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang.ArrayUtils
的用法示例。
在下文中一共展示了ArrayUtils.removeElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ignoreHttpRequest
import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
private Object[] ignoreHttpRequest(Object[] args) {
if (args == null) return null;
for (Object o : args) {
if (o instanceof HttpServletRequest) {
args = ArrayUtils.removeElement(args, o);
return args;
}
}
return args;
}
示例2: testUpdateCollectionMediaItems
import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
public void testUpdateCollectionMediaItems() {
MediaCollection coll;
List<MediaItem> items;
String[] kalturaIds;
// SUPER ADMIN
external.currentUserId = KalturaAPIServiceStub.ADMIN_USER_ID;
coll = service.getCollection(kalturaAPIService.mcAd.getIdStr(), 0, -1);
assertNotNull(coll);
assertTrue(coll.isAddItems());
items = coll.getItems();
assertEquals(5, items.size());
kalturaIds = coll.getKalturaIds().toArray(new String[items.size()]);
service.updateCollectionMediaItems(coll.getId(), kalturaIds);
coll = service.getCollection(kalturaAPIService.mcAd.getIdStr(), 0, -1);
assertEquals(5, coll.getItems().size()); // no change in size
// test adding one
coll = service.getCollection(kalturaAPIService.mcAd.getIdStr(), 0, -1);
assertNotNull(coll);
assertTrue(coll.isAddItems());
items = coll.getItems();
assertEquals(5, items.size());
kalturaIds = coll.getKalturaIds().toArray(new String[items.size()]);
kalturaIds = (String[]) ArrayUtils.add(kalturaIds, "kid7");
service.updateCollectionMediaItems(coll.getId(), kalturaIds);
coll = service.getCollection(kalturaAPIService.mcAd.getIdStr(), 0, -1);
assertEquals(6, coll.getItems().size()); // +1 size
assertTrue(coll.getKalturaIds().contains("kid7"));
// test removing one
coll = service.getCollection(kalturaAPIService.mcAd.getIdStr(), 0, -1);
assertNotNull(coll);
assertTrue(coll.isAddItems());
items = coll.getItems();
assertEquals(6, items.size());
kalturaIds = coll.getKalturaIds().toArray(new String[items.size()]);
kalturaIds = (String[]) ArrayUtils.removeElement(kalturaIds, "kid7");
service.updateCollectionMediaItems(coll.getId(), kalturaIds);
coll = service.getCollection(kalturaAPIService.mcAd.getIdStr(), 0, -1);
assertEquals(5, coll.getItems().size()); // -1 size
assertFalse(coll.getKalturaIds().contains("kid7"));
// testing adding and removing
coll = service.getCollection(kalturaAPIService.mcAd.getIdStr(), 0, -1);
assertNotNull(coll);
assertTrue(coll.isAddItems());
items = coll.getItems();
assertEquals(5, items.size());
kalturaIds = coll.getKalturaIds().toArray(new String[items.size()]);
kalturaIds = (String[]) ArrayUtils.removeElement(kalturaIds, "kid5");
kalturaIds = (String[]) ArrayUtils.add(kalturaIds, "kidA");
kalturaIds = (String[]) ArrayUtils.add(kalturaIds, "kidB");
service.updateCollectionMediaItems(coll.getId(), kalturaIds);
coll = service.getCollection(kalturaAPIService.mcAd.getIdStr(), 0, -1);
assertEquals(6, coll.getItems().size()); // -1 +2 size
assertFalse(coll.getKalturaIds().contains("kid5"));
assertTrue(coll.getKalturaIds().contains("kidA"));
assertTrue(coll.getKalturaIds().contains("kidB"));
}