本文整理匯總了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"));
}