本文整理汇总了Java中com.wm.data.IDataUtil.getIDataArray方法的典型用法代码示例。如果您正苦于以下问题:Java IDataUtil.getIDataArray方法的具体用法?Java IDataUtil.getIDataArray怎么用?Java IDataUtil.getIDataArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.wm.data.IDataUtil
的用法示例。
在下文中一共展示了IDataUtil.getIDataArray方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filterSample
import com.wm.data.IDataUtil; //导入方法依赖的package包/类
public static final void filterSample(IData pipeline) throws ServiceException {
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
// indocs
IData[] indocs = IDataUtil.getIDataArray( pipelineCursor, "indocs" );
pipelineCursor.destroy();
java.util.List<IData> idataList = (java.util.List) Arrays.asList(indocs);
java.util.List<IData> result = idataList.stream()
.filter( idata -> idata.toString().indexOf("street=ABCStreet 42") > -1)
.collect(Collectors.toList());
result.stream()
.forEach(System.out::println);
// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
// outdocs
IDataUtil.put( pipelineCursor_1, "outdocs", result.toArray() );
pipelineCursor_1.destroy();
}
开发者ID:ThomasToepperwien,项目名称:webmethods-integrationserver-java8-stream-filtering,代码行数:27,代码来源:Java8Streaming.java
示例2: convertObjectArrays
import com.wm.data.IDataUtil; //导入方法依赖的package包/类
@Test
public void convertObjectArrays() throws Exception
{
final Person person1 = createPerson("Stefan", "Macke");
final Person person2 = createPerson("Hans", "Meier");
final IData person1IData = createPersonIData(person1);
final IData person2IData = createPersonIData(person2);
final IData expected = createIData("people", new IData[]
{ person1IData, person2IData });
final IData actual = sut.convertToIData("people", new Person[]
{ person1, person2 });
assertIDataEquals(actual, expected);
final IData[] actualArray = IDataUtil.getIDataArray(actual.getCursor(), "people");
final IData[] expectedArray = IDataUtil.getIDataArray(expected.getCursor(), "people");
assertThat(actualArray.getClass().toString(), is(expectedArray.getClass().toString()));
}
示例3: convertObjectLists
import com.wm.data.IDataUtil; //导入方法依赖的package包/类
@Test
public void convertObjectLists() throws Exception
{
final Person person1 = createPerson("Stefan", "Macke");
final Person person2 = createPerson("Hans", "Meier");
final IData person1IData = createPersonIData(person1);
final IData person2IData = createPersonIData(person2);
final IData expected = createIData("people", new IData[]
{ person1IData, person2IData });
final IData actual = sut.convertToIData("people", Arrays.asList(new Person[]
{ person1, person2 }));
assertIDataEquals(actual, expected);
final IData[] actualArray = IDataUtil.getIDataArray(actual.getCursor(), "people");
final IData[] expectedArray = IDataUtil.getIDataArray(expected.getCursor(), "people");
assertThat(actualArray.getClass().toString(), is(expectedArray.getClass().toString()));
}
示例4: encodeToString
import com.wm.data.IDataUtil; //导入方法依赖的package包/类
/**
* Returns a CSV representation of the given IData object.
*
* @param document The IData to convert to CSV.
* @return The CSV representation of the IData.
*/
@Override
public String encodeToString(IData document) throws IOException {
if (document == null) return null;
IDataCursor cursor = document.getCursor();
IData[] records = IDataUtil.getIDataArray(cursor, "recordWithNoID");
cursor.destroy();
if (records == null) return null;
if (records.length == 0) return "";
String[] columns = this.columns;
if (columns == null || columns.length == 0) columns = IDataHelper.getKeys(records);
StringBuilder builder = new StringBuilder();
CSVPrinter printer = new CSVPrinter(builder, formatter(columns));
for (IData record : records) {
if (record != null) printer.printRecord(IDataHelper.getValues(record));
}
return builder.toString();
}
示例5: testDecodeFromString
import com.wm.data.IDataUtil; //导入方法依赖的package包/类
@Test
public void testDecodeFromString() throws Exception {
String csv = "name,email\nJohn,[email protected]\nJean,[email protected]\nBill,[email protected]";
IData document = IDataCSVParser.getInstance().decodeFromString(csv);
IDataCursor cursor = document.getCursor();
IData[] records = IDataUtil.getIDataArray(cursor, "recordWithNoID");
cursor.destroy();
assertEquals(3, records.length);
cursor = records[0].getCursor();
assertEquals("John", IDataUtil.getString(cursor, "name"));
assertEquals("[email protected]", IDataUtil.getString(cursor, "email"));
cursor.destroy();
cursor = records[1].getCursor();
assertEquals("Jean", IDataUtil.getString(cursor, "name"));
assertEquals("[email protected]", IDataUtil.getString(cursor, "email"));
cursor.destroy();
cursor = records[2].getCursor();
assertEquals("Bill", IDataUtil.getString(cursor, "name"));
assertEquals("[email protected]", IDataUtil.getString(cursor, "email"));
cursor.destroy();
}
示例6: testDecodeFromStringWithCustomDelimiter
import com.wm.data.IDataUtil; //导入方法依赖的package包/类
@Test
public void testDecodeFromStringWithCustomDelimiter() throws Exception {
String csv = "name|email\nJohn|[email protected]\nJean|[email protected]\nBill|[email protected]";
IDataCSVParser parser = new IDataCSVParser("|");
IData document = parser.decodeFromString(csv);
IDataCursor cursor = document.getCursor();
IData[] records = IDataUtil.getIDataArray(cursor, "recordWithNoID");
cursor.destroy();
assertEquals(3, records.length);
cursor = records[0].getCursor();
assertEquals("John", IDataUtil.getString(cursor, "name"));
assertEquals("[email protected]", IDataUtil.getString(cursor, "email"));
cursor.destroy();
cursor = records[1].getCursor();
assertEquals("Jean", IDataUtil.getString(cursor, "name"));
assertEquals("[email protected]", IDataUtil.getString(cursor, "email"));
cursor.destroy();
cursor = records[2].getCursor();
assertEquals("Bill", IDataUtil.getString(cursor, "name"));
assertEquals("[email protected]", IDataUtil.getString(cursor, "email"));
cursor.destroy();
}
示例7: encodeToString
import com.wm.data.IDataUtil; //导入方法依赖的package包/类
/**
* Returns an HTML representation of the given IData object.
*
* @param input The IData to convert to HTML.
* @param buffer The StringBuilder to append the HTML to.
* @param maxDepth The maximum depth children will be encoded to.
* @param currentDepth The current depth being encoded.
*/
protected void encodeToString(IData input, StringBuilder buffer, int maxDepth, int currentDepth) {
input = IDataHelper.normalize(input);
int size = IDataHelper.size(input);
if (size == 0) {
buffer.append(HTMLEntity.EMPTY.toString());
} else if (currentDepth >= maxDepth) {
buffer.append(HTMLEntity.HORIZONTAL_ELLIPSIS.toString());
} else {
IDataCursor cursor = input.getCursor();
IData[] array = IDataUtil.getIDataArray(cursor, "recordWithNoID");
cursor.destroy();
if (array != null) {
encodeToString(array, buffer, maxDepth, currentDepth);
} else {
// table
buffer.append("<table class=\"IData\">");
// thead
buffer.append("<thead>");
buffer.append("<tr>");
buffer.append("<th>Key</th>");
buffer.append("<th>Value</th>");
buffer.append("</tr>");
buffer.append("</thead>");
// tbody
buffer.append("<tbody>");
cursor = input.getCursor();
while(cursor.next()) {
String key = cursor.getKey();
Object value = cursor.getValue();
buffer.append("<tr>");
buffer.append("<th>");
buffer.append(HTMLHelper.encode(key));
buffer.append("</th>");
buffer.append("<td>");
if (value == null) {
buffer.append(HTMLEntity.NULL.toString());
} else {
if (value instanceof IData[] || value instanceof Table || value instanceof IDataCodable[] || value instanceof IDataPortable[] || value instanceof ValuesCodable[]) {
encodeToString(IDataHelper.toIDataArray(value), buffer, maxDepth, currentDepth + 1);
} else if (value instanceof IData || value instanceof IDataCodable || value instanceof IDataPortable || value instanceof ValuesCodable) {
encodeToString(IDataHelper.toIData(value), buffer, maxDepth, currentDepth + 1);
} else if (value instanceof Object[][]) {
encodeToString((Object[][])value, buffer);
} else if (value instanceof Object[]) {
encodeToString((Object[])value, buffer);
} else {
buffer.append(HTMLHelper.encode(value.toString()));
}
}
buffer.append("</td>");
buffer.append("</tr>");
}
cursor.destroy();
buffer.append("</tbody>");
buffer.append("</table>");
}
}
}
示例8: put
import com.wm.data.IDataUtil; //导入方法依赖的package包/类
/**
* Sets the value associated with the given key in the given IData document. Note that this method mutates the given
* IData document in place.
*
* @param document An IData document.
* @param key A fully-qualified key identifying the value to be set.
* @param value The value to be set.
* @param includeNull When true the value is set even when null, otherwise the value is only set when it is
* not null.
* @return The input IData document with the value set.
*/
private static IData put(IData document, IDataKey key, Object value, boolean includeNull) {
if (!includeNull && value == null) return document;
if (key != null && key.size() > 0) {
if (document == null) document = IDataFactory.create();
IDataCursor cursor = document.getCursor();
IDataKey.Part keyPart = key.remove();
if (key.size() > 0) {
if (keyPart.hasArrayIndex()) {
IData[] array = IDataUtil.getIDataArray(cursor, keyPart.getKey());
IData child = null;
try {
child = ArrayHelper.get(array, keyPart.getIndex());
} catch(ArrayIndexOutOfBoundsException ex) {
// ignore exception
}
value = ArrayHelper.put(array, put(child, key, value, includeNull), keyPart.getIndex(), IData.class);
} else if (keyPart.hasKeyIndex()) {
value = put(toIData(get(document, keyPart.getKey(), keyPart.getIndex())), key, value, includeNull);
} else {
value = put(IDataUtil.getIData(cursor, keyPart.getKey()), key, value, includeNull);
}
} else if (keyPart.hasArrayIndex()) {
Class klass = Object.class;
if (value != null) {
if (value instanceof String) {
klass = String.class;
} else if (value instanceof IData) {
klass = IData.class;
}
}
value = ArrayHelper.put(IDataUtil.getObjectArray(cursor, keyPart.getKey()), value, keyPart.getIndex(), klass);
}
if (keyPart.hasKeyIndex()) {
put(document, keyPart.getKey(), keyPart.getIndex(), value);
} else {
IDataUtil.put(cursor, keyPart.getKey(), value);
}
cursor.destroy();
}
return document;
}
示例9: getReferences
import com.wm.data.IDataUtil; //导入方法依赖的package包/类
/**
* Returns the list of elements referenced by the services in the given package.
*
* @param pkg The package to get references for.
* @return The list of references for the given package.
*/
public static IData getReferences(Package pkg) {
String[] services = toStringArray(IterableEnumeration.of(pkg.getLoaded()));
DependencyManager manager = NSDependencyManager.current();
Namespace namespace = Namespace.current();
SortedSet<String> packages = new TreeSet<String>();
SortedMap<String, IData> resolved = new TreeMap<String, IData>();
SortedSet<String> unresolved = new TreeSet<String>();
for (String service : services) {
if (service != null) {
NSNode node = namespace.getNode(service);
IData results = manager.getReferenced(node, null);
if (results != null) {
IDataCursor resultsCursor = results.getCursor();
IData[] references = IDataUtil.getIDataArray(resultsCursor, "reference");
resultsCursor.destroy();
if (references != null) {
for (IData reference : references) {
if (reference != null) {
IDataCursor referenceCursor = reference.getCursor();
String name = IDataUtil.getString(referenceCursor, "name");
String status = IDataUtil.getString(referenceCursor, "status");
referenceCursor.destroy();
if (status.equals("unresolved")) {
unresolved.add(name);
} else {
String[] parts = name.split("\\/");
if (parts.length > 1) {
if (!pkg.getName().equals(parts[0])) {
IData result = IDataFactory.create();
IDataCursor resultCursor = result.getCursor();
IDataUtil.put(resultCursor, "package", parts[0]);
IDataUtil.put(resultCursor, "node", parts[1]);
resultCursor.destroy();
packages.add(parts[0]);
resolved.put(name, result);
}
}
}
}
}
}
}
}
}
IData output = IDataFactory.create();
IDataCursor cursor = output.getCursor();
IDataUtil.put(cursor, "packages", packages.toArray(new String[packages.size()]));
IDataUtil.put(cursor, "packages.length", IntegerHelper.emit(packages.size()));
IDataUtil.put(cursor, "nodes", resolved.values().toArray(new IData[resolved.size()]));
IDataUtil.put(cursor, "nodes.length", IntegerHelper.emit(resolved.size()));
IDataUtil.put(cursor, "unresolved", unresolved.toArray(new String[unresolved.size()]));
IDataUtil.put(cursor, "unresolved.length", IntegerHelper.emit(unresolved.size()));
cursor.destroy();
return output;
}
示例10: getDependents
import com.wm.data.IDataUtil; //导入方法依赖的package包/类
/**
* Returns the list of services that are dependent on the services in the given package.
*
* @param pkg The package to get dependents for.
* @return The list of dependents for the given package.
*/
private static IData getDependents(Package pkg) {
String[] services = toStringArray(IterableEnumeration.of(pkg.getLoaded()));
DependencyManager manager = NSDependencyManager.current();
Namespace namespace = Namespace.current();
SortedSet<String> packages = new TreeSet<String>();
SortedMap<String, IData> nodes = new TreeMap<String, IData>();
for (String service : services) {
if (service != null) {
NSNode node = namespace.getNode(service);
if (node != null) {
IData results = manager.getDependent(node, null);
if (results != null) {
IDataCursor resultsCursor = results.getCursor();
IData[] referencedBy = IDataUtil.getIDataArray(resultsCursor, "referencedBy");
resultsCursor.destroy();
if (referencedBy != null) {
for (IData dependent : referencedBy) {
if (dependent != null) {
IDataCursor dependentCursor = dependent.getCursor();
String name = IDataUtil.getString(dependentCursor, "name");
dependentCursor.destroy();
String[] parts = name.split("\\/");
if (parts.length > 1) {
if (!pkg.getName().equals(parts[0])) {
IData result = IDataFactory.create();
IDataCursor resultCursor = result.getCursor();
IDataUtil.put(resultCursor, "package", parts[0]);
IDataUtil.put(resultCursor, "node", parts[1]);
resultCursor.destroy();
packages.add(parts[0]);
nodes.put(name, result);
}
}
}
}
}
}
}
}
}
IData output = IDataFactory.create();
IDataCursor cursor = output.getCursor();
IDataUtil.put(cursor, "packages", packages.toArray(new String[packages.size()]));
IDataUtil.put(cursor, "packages.length", IntegerHelper.emit(packages.size()));
IDataUtil.put(cursor, "nodes", nodes.values().toArray(new IData[nodes.size()]));
IDataUtil.put(cursor, "nodes.length", IntegerHelper.emit(nodes.size()));
cursor.destroy();
return output;
}
示例11: getDependents
import com.wm.data.IDataUtil; //导入方法依赖的package包/类
/**
* Returns the list of services that are dependent on the given list of services.
*
* @param services The services to get dependents for.
* @return The list of dependents for the given services.
*/
public static IData getDependents(String ...services) {
DependencyManager manager = NSDependencyManager.current();
Namespace namespace = Namespace.current();
SortedSet<String> packages = new TreeSet<String>();
SortedMap<String, IData> nodes = new TreeMap<String, IData>();
if (services != null) {
for (String service : services) {
if (service != null) {
NSNode node = namespace.getNode(service);
if (node != null) {
IData results = manager.getDependent(node, null);
if (results != null) {
IDataCursor resultsCursor = results.getCursor();
IData[] referencedBy = IDataUtil.getIDataArray(resultsCursor, "referencedBy");
resultsCursor.destroy();
if (referencedBy != null) {
for (IData dependent : referencedBy) {
if (dependent != null) {
IDataCursor dependentCursor = dependent.getCursor();
String name = IDataUtil.getString(dependentCursor, "name");
dependentCursor.destroy();
String[] parts = name.split("\\/");
if (parts.length > 1) {
IData result = IDataFactory.create();
IDataCursor resultCursor = result.getCursor();
IDataUtil.put(resultCursor, "package", parts[0]);
IDataUtil.put(resultCursor, "node", parts[1]);
resultCursor.destroy();
packages.add(parts[0]);
nodes.put(name, result);
}
}
}
}
}
}
}
}
}
IData output = IDataFactory.create();
IDataCursor cursor = output.getCursor();
IDataUtil.put(cursor, "packages", packages.toArray(new String[packages.size()]));
IDataUtil.put(cursor, "packages.length", IntegerHelper.emit(packages.size()));
IDataUtil.put(cursor, "nodes", nodes.values().toArray(new IData[nodes.size()]));
IDataUtil.put(cursor, "nodes.length", IntegerHelper.emit(nodes.size()));
cursor.destroy();
return output;
}
示例12: getReferences
import com.wm.data.IDataUtil; //导入方法依赖的package包/类
/**
* Returns the list of elements referenced by the given list of services.
*
* @param services The list of services to get references for.
* @return The list of references for the given services.
*/
public static IData getReferences(String ...services) {
DependencyManager manager = NSDependencyManager.current();
Namespace namespace = Namespace.current();
SortedSet<String> packages = new TreeSet<String>();
SortedMap<String, IData> resolved = new TreeMap<String, IData>();
SortedSet<String> unresolved = new TreeSet<String>();
if (services != null) {
for (String service : services) {
if (service != null) {
NSNode node = namespace.getNode(service);
IData results = manager.getReferenced(node, null);
if (results != null) {
IDataCursor resultsCursor = results.getCursor();
IData[] references = IDataUtil.getIDataArray(resultsCursor, "reference");
resultsCursor.destroy();
if (references != null) {
for (IData reference : references) {
if (reference != null) {
IDataCursor referenceCursor = reference.getCursor();
String name = IDataUtil.getString(referenceCursor, "name");
String status = IDataUtil.getString(referenceCursor, "status");
referenceCursor.destroy();
if (status.equals("unresolved")) {
unresolved.add(name);
} else {
String[] parts = name.split("\\/");
if (parts.length > 1) {
IData result = IDataFactory.create();
IDataCursor resultCursor = result.getCursor();
IDataUtil.put(resultCursor, "package", parts[0]);
IDataUtil.put(resultCursor, "node", parts[1]);
resultCursor.destroy();
packages.add(parts[0]);
resolved.put(name, result);
}
}
}
}
}
}
}
}
}
IData output = IDataFactory.create();
IDataCursor cursor = output.getCursor();
IDataUtil.put(cursor, "packages", packages.toArray(new String[packages.size()]));
IDataUtil.put(cursor, "packages.length", IntegerHelper.emit(packages.size()));
IDataUtil.put(cursor, "nodes", resolved.values().toArray(new IData[resolved.size()]));
IDataUtil.put(cursor, "nodes.length", IntegerHelper.emit(resolved.size()));
IDataUtil.put(cursor, "unresolved", unresolved.toArray(new String[unresolved.size()]));
IDataUtil.put(cursor, "unresolved.length", IntegerHelper.emit(unresolved.size()));
cursor.destroy();
return output;
}
示例13: submit
import com.wm.data.IDataUtil; //导入方法依赖的package包/类
public static final void submit (IData pipeline)
throws ServiceException
{
// --- <<IS-START(submit)>> ---
// @sigtype java 3.5
// [i] record:1:required services
// [i] - field:0:required serviceName
// [i] - record:0:optional input
// [i] - field:0:optional priority {"1","2","3","4","5","6","7","8","9","10"}
// [i] field:0:required pool
// [i] field:0:optional deepClone {"true","false"}
// [o] object:1:required futures
IDataCursor pipelineCur = pipeline.getCursor();
try {
IData[] services = IDataUtil.getIDataArray(pipelineCur, "services");
if(services == null || services.length == 0) {
return;
}
String pool = IDataUtil.getString(pipelineCur, "pool");
boolean deepClone = Boolean.valueOf(IDataUtil.getString(pipelineCur, "deepClone"));
IDataCursor servicesCur = null;
List<Future> futures = new ArrayList<Future>();
for(int i=0; i<services.length; i++) {
servicesCur = services[i].getCursor();
String serviceName = IDataUtil.getString(servicesCur, "serviceName");
IData input = IDataUtil.getIData(servicesCur, "input");
String sPriority = IDataUtil.getString(servicesCur, "priority");
if(deepClone) {
futures.add(ReactiveWMFacade.submit(pool, serviceName, getPriority(sPriority), IDataUtil.deepClone(input)));
} else {
futures.add(ReactiveWMFacade.submit(pool, serviceName, getPriority(sPriority), input));
}
}
if(futures == null || futures.size() != 0) {
IDataUtil.put(pipelineCur, "futures", futures.toArray(new Future[futures.size()]));
}
if(servicesCur != null) {
servicesCur.destroy();
}
} catch(Exception e) {
throw new ServiceException(e);
} finally {
if(pipelineCur != null) {
pipelineCur.destroy();
}
}
// --- <<IS-END>> ---
}