Search in sources :

Example 1 with NameValuePair

use of org.apache.uima.resource.metadata.NameValuePair in project dkpro-tc by dkpro.

the class DiscriminableNameConverter method addParameters.

private static List<String> addParameters(List<String> entries, NameValuePair[] parameterSettings) {
    for (int i = 0; i < parameterSettings.length; i++) {
        NameValuePair nvp = parameterSettings[i];
        Object value = nvp.getValue();
        StringBuilder sb = new StringBuilder();
        if (value instanceof Object[]) {
            Object[] x = (Object[]) value;
            for (int k = 0; k < x.length; k++) {
                Object object = x[k];
                sb.append(object);
                if (k + 1 < x.length) {
                    sb.append(", ");
                }
            }
            entries.add(nvp.getName() + "=" + sb.toString());
        } else {
            entries.add(nvp.getName() + "=" + nvp.getValue());
        }
    }
    return entries;
}
Also used : NameValuePair(org.apache.uima.resource.metadata.NameValuePair)

Example 2 with NameValuePair

use of org.apache.uima.resource.metadata.NameValuePair in project dkpro-tc by dkpro.

the class DiscriminableNameConverter method getCollectionReaderDescription.

public static String getCollectionReaderDescription(CollectionReaderDescription crd) {
    ResourceMetaData metaData = crd.getMetaData();
    ConfigurationParameterSettings settings = metaData.getConfigurationParameterSettings();
    NameValuePair[] params = settings.getParameterSettings();
    String implementationName = crd.getImplementationName();
    List<String> entries = new ArrayList<>();
    entries.add(implementationName);
    entries = addParameters(entries, params);
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < entries.size(); i++) {
        sb.append(entries.get(i));
        if (i + 1 < entries.size()) {
            sb.append(", ");
        }
    }
    String description = "[" + sb.toString() + "]";
    return description;
}
Also used : ConfigurationParameterSettings(org.apache.uima.resource.metadata.ConfigurationParameterSettings) NameValuePair(org.apache.uima.resource.metadata.NameValuePair) ArrayList(java.util.ArrayList) ResourceMetaData(org.apache.uima.resource.metadata.ResourceMetaData)

Aggregations

NameValuePair (org.apache.uima.resource.metadata.NameValuePair)2 ArrayList (java.util.ArrayList)1 ConfigurationParameterSettings (org.apache.uima.resource.metadata.ConfigurationParameterSettings)1 ResourceMetaData (org.apache.uima.resource.metadata.ResourceMetaData)1