WEBMETHODS では、DocumentList をループ中に DocumentList から要素を削除できますか? はいの場合、どのように?いいえの場合、DocumentList 変数の値を null に設定するにはどうすればよいでしょうか。
ありがとう
_
WEBMETHODS では、DocumentList をループ中に DocumentList から要素を削除できますか? はいの場合、どのように?いいえの場合、DocumentList 変数の値を null に設定するにはどうすればよいでしょうか。
ありがとう
_
Tundraには、ドキュメント リスト ( com.wm.data.IData[]
)からアイテムを削除するためのサービスが含まれていますtundra.list.document:drop($list[], $index)
。
$list
com.wm.data.IData[]
アイテムを削除するドキュメント リスト ( ) です。$index
ドロップする項目のゼロベースの配列インデックスです関連する Java コードは次のとおりです。
public static final void drop(IData pipeline) throws ServiceException {
IDataCursor cursor = pipeline.getCursor();
try {
Object[] list = IDataUtil.getObjectArray(cursor, "$list");
String index = IDataUtil.getString(cursor, "$index");
if (index != null) IDataUtil.put(cursor, "$list", drop(list, index));
} finally {
cursor.destroy();
}
}
// returns a new array which contains all the elements from the given arrays
public static <T> T[] concatenate(T[] array, T[] items) {
if (array == null) return items;
if (items == null) return array;
java.util.List<T> list = new java.util.ArrayList<T>(array.length + items.length);
java.util.Collections.addAll(list, array);
java.util.Collections.addAll(list, items);
return list.toArray(java.util.Arrays.copyOf(array, 0));
}
// removes the element at the given index from the given list
public static <T> T[] drop(T[] array, String index) {
return drop(array, Integer.parseInt(index));
}
// removes the element at the given index from the given list
public static <T> T[] drop(T[] array, int index) {
if (array != null) {
// support reverse/tail indexing
if (index < 0) index += array.length;
if (index < 0 || array.length <= index) throw new ArrayIndexOutOfBoundsException(index);
T[] head = slice(array, 0, index);
T[] tail = slice(array, index + 1, array.length - index);
array = concatenate(head, tail);
}
return array;
}
// returns a new array which is a subset of elements from the given array
public static <T> T[] slice(T[] array, int index, int length) {
if (array == null || array.length == 0) return array;
// support reverse/tail length
if (length < 0) length = array.length + length;
// support reverse/tail indexing
if (index < 0) index += array.length;
// don't slice past the end of the array
if ((length += index) > array.length) length = array.length;
return java.util.Arrays.copyOfRange(array, index, length);
}
しかし、私はMrJamesに同意します: 最善かつ最も簡単な方法は、新しいドキュメント リストを作成し、ループ ステップ内でpub.list:appendToDocumentList
(またはTundratundra.list.document:append
を使用している場合は) を使用して、必要な項目のみを新しいリストに追加することです。
私はいくつかのテストを行い、特定の Document 項目を null に設定することは可能ですが (サービス pub.list:setListItem を使用)、ドキュメント リストは同じサイズのままです。
もう 1 つの方法は、ドキュメント リストをループして、関心のあるドキュメント リストを新しいドキュメント リストに追加することです (pub.list:appendToDocumentList)。
変数を null に設定する方法に関するもう 1 つの質問は、パイプラインで Drop を使用できます
PS: webMethods 7.1.2 を使用