Il numero di elementi in output è determinato dal numero di elementi dell’array, risultato della RemoveContext o della CollapseContext, e non dal numero di contesti, risultato della SplitByValue.
Determina 4 elementi in output
Determina un solo elemento in output e precisamente il primo
Questo snippet si applica quando, a fronte di due differenti contesti correlati fra loro, si vogliono ottenere più contesti che rappresentino la correlazione.
Un esempio può essere il contesto TESTI con testi in lingua diversa ed il contesto LINGUE DEI TESTI. Si vogliono ottenere tanti contesti quante sono le lingue e in ciascun contesto i testi per quelle lingue.
Il requisito è che il contesto LINGUE DEI TESTI sia ordinato e che gli item del contesto dei TESTI siano in corrispondenza con gli item del contesto LINGUE DEI TESTI.
public void SplitByValueChange(String[] data, String[] criteria, ResultList result, Container container) throws StreamTransformationException{
/*
Dati due array in input, data e criteria, genera tanti contesti di data quante sono le rotture di livello di criteria.
Nessuno dei due array dev'essere vuoto o null e la dimensione di entrambi dev'essere la stessa.
*/
result.clear();
if( StringManager.isArrayNull(criteria) || StringManager.isArrayNull(data)) {
return;
}
if( criteria.length != data.length ){
return;
}
String t = criteria[0];
for (int i = 0; i < criteria.length; i++){
if(!criteria[i].equals(t)){
result.addContextChange();
t = criteria[i];
}
result.addValue(data[i]);
}
}
Questo snippet è utile quando si vuole operare su un contesto applicando più filtri in cascata.
Nell’esempio sotto si vuole creare un contesto di “record 2” e, all’interno di questo, raggruppare in singoli sotto-contesti record 2 con la stessa lingua.
public String CtxPassthrough(String newContext, String currentContext, Container container)
throws StreamTransformationException{
/*
Consente di mantenere attivo un contesto, quello passato al parametro currentContext,
e contemporaneamente di generarne un altro passandolo al parametro newContext.
In output ritorna il parametro newContext senza alcuna trasformazione.
*/
return newContext;
}
This website uses technical cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptRead More
Privacy & Cookies Policy
Privacy Overview
This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.