List of usage examples for java.util LinkedHashMap get
public V get(Object key)
From source file:edu.jhuapl.openessence.web.util.ControllerUtils.java
/** * Returns a new map that is sorted and then limited to the top {@code limit} values. It then places the map back * in the original sort order minus anything that has been cut. *///from ww w . ja v a 2 s . c o m public static LinkedHashMap<String, Double> getSortedAndLimitedMap(LinkedHashMap<String, Double> map, Integer limit, String limitLabel) { //test if we need to trim if (limit <= 0 || limit >= map.size()) { return map; } //sort by value Map<String, Double> sortedMap = ControllerUtils.getSortedByValueMap(map); //limit and combine results Map<String, Double> sortedLimitedMap = ControllerUtils.getLimitedMap(sortedMap, limit, limitLabel); //put the original sort order back (minus the values combined) LinkedHashMap<String, Double> originalSortResultMap = new LinkedHashMap<String, Double>(limit); LinkedHashMap<String, Double> passedValuesMap = new LinkedHashMap<String, Double>(map.size()); int i = 0; for (String key : map.keySet()) { if (i < limit) { if (sortedLimitedMap.containsKey(key)) { Double value = sortedLimitedMap.get(key); //if value is not null/zero, add it and increment if (value != null && !Double.isNaN(value) && value > 0) { originalSortResultMap.put(key, value); i++; } else { //put it in a list of passed up values for inclusion at the end passedValuesMap.put(key, value); } } } } //if we still have room after adding all sorted non zero values... fill the rest with passed values if (i < limit) { for (String key : passedValuesMap.keySet()) { if (i < limit) { originalSortResultMap.put(key, passedValuesMap.get(key)); i++; } } } //add combined field if it is not null (indicates it was used even if the value is 0) Double cVal = sortedLimitedMap.get(limitLabel); if (cVal != null && !Double.isNaN(cVal)) { originalSortResultMap.put(limitLabel, cVal); } return originalSortResultMap; }
From source file:marytts.modules.ModuleRegistry.java
/** * Lookup a list of modules for the given combination of type, locale and voice. * A given lookup will return a list of modules accepting the datatype as input, * ordered by specificity so that the most specific modules come first. * For each output type produced by modules, there will be only one module * producing that type, namely the most specific one found. * Specificity is ordered as follows:// w ww .j av a 2 s .c o m * 1. most specific is the full combination of datatype, locale and voice; * 2. the combination of datatype, language-only locale and voice (i.e., for requested locale "en-US" will find modules with locale "en"); * 3. the combination of datatype and locale, ignoring voice; * 4. the combination of datatype and language-only locale, ignoring voice; * 5. least specific is the datatype, ignoring locale and voice. * @param type the type of input data * @param locale the locale * @param voice the voice to use. * @return a list of mary modules accepting the datatype and suitable for * the given locale and voice, ordered by their specificity, * or an empty list if there is no suitable module. * @throws IllegalStateException if called when registration is not yet complete. */ @SuppressWarnings("unchecked") private static List<MaryModule> get(MaryDataType type, Locale locale, Voice voice) throws IllegalStateException { if (!registrationComplete) throw new IllegalStateException("Cannot inquire about modules while registration is ongoing"); LinkedHashMap<MaryDataType, MaryModule> results = new LinkedHashMap<MaryDataType, MaryModule>(); // First, get all results: List<List<MaryModule>> listOfLists = new LinkedList<List<MaryModule>>(); listOfLists.add((List<MaryModule>) mkm.get(type, locale, voice)); Locale langOnly = locale != null ? new Locale(locale.getLanguage()) : null; boolean haveCountry = langOnly == null ? false : !langOnly.equals(locale); if (haveCountry) { listOfLists.add((List<MaryModule>) mkm.get(type, langOnly, voice)); } listOfLists.add((List<MaryModule>) mkm.get(type, locale, null)); if (haveCountry) { listOfLists.add((List<MaryModule>) mkm.get(type, langOnly, null)); } listOfLists.add((List<MaryModule>) mkm.get(type, null, null)); // Now, for each mary output type, keep only the most specific module, // and return the list ordered by the specificity of modules (most specific first): for (List<MaryModule> list : listOfLists) { if (list != null) { for (MaryModule m : list) { if (!results.containsKey(m.outputType())) results.put(m.outputType(), m); } } } List<MaryModule> returnList = new LinkedList<MaryModule>(); for (MaryDataType t : results.keySet()) { returnList.add(results.get(t)); } return returnList; }
From source file:net.sf.jasperreports.engine.fill.DelayedFillActions.java
protected void readElementEvaluations(JRVirtualizable<VirtualElementsData> object) { JRVirtualPrintPage page = ((VirtualizablePageElements) object).getPage();// ugly but needed for now FillPageKey pageKey = new FillPageKey(page); for (Map.Entry<JREvaluationTime, LinkedHashMap<FillPageKey, LinkedMap<Object, EvaluationBoundAction>>> boundMapEntry : actionsMap .entrySet()) {// w w w.ja v a2 s. c o m JREvaluationTime evaluationTime = boundMapEntry.getKey(); LinkedHashMap<FillPageKey, LinkedMap<Object, EvaluationBoundAction>> map = boundMapEntry.getValue(); synchronized (map) { LinkedMap<Object, EvaluationBoundAction> actionsMap = map.get(pageKey); readElementEvaluations(object, id, evaluationTime, actionsMap); if (transferredIds != null) { //FIXMEBOOK does this have any effect on the order of the actions? for (Integer transferredId : transferredIds) { readElementEvaluations(object, transferredId, evaluationTime, actionsMap); } } } } }
From source file:com.chen.ex.chips.BaseRecipientAdapter.java
private static void putOneEntry(TemporaryEntry entry, boolean isAggregatedEntry, LinkedHashMap<Long, List<RecipientEntry>> entryMap, List<RecipientEntry> nonAggregatedEntries, Set<String> existingDestinations) { if (existingDestinations.contains(entry.destination)) { return;/*from w ww .j a v a 2 s . c o m*/ } existingDestinations.add(entry.destination); if (!isAggregatedEntry) { nonAggregatedEntries.add(RecipientEntry.constructTopLevelEntry(entry.displayName, entry.displayNameSource, entry.destination, entry.destinationType, entry.destinationLabel, entry.contactId, entry.dataId, entry.thumbnailUriString, true)); } else if (entryMap.containsKey(entry.contactId)) { // We already have a section for the person. final List<RecipientEntry> entryList = entryMap.get(entry.contactId); entryList.add(RecipientEntry.constructSecondLevelEntry(entry.displayName, entry.displayNameSource, entry.destination, entry.destinationType, entry.destinationLabel, entry.contactId, entry.dataId, entry.thumbnailUriString, true)); } else { final List<RecipientEntry> entryList = new ArrayList<RecipientEntry>(); entryList.add(RecipientEntry.constructTopLevelEntry(entry.displayName, entry.displayNameSource, entry.destination, entry.destinationType, entry.destinationLabel, entry.contactId, entry.dataId, entry.thumbnailUriString, true)); entryMap.put(entry.contactId, entryList); } }
From source file:com.predic8.membrane.core.interceptor.apimanagement.ApiManagementConfiguration.java
private Map<String, Policy> parsePolicies(Map<String, Object> yaml) { Map<String, Policy> result = new HashMap<String, Policy>(); Object policies = yaml.get("policies"); if (policies == null) { log.warn("\"policies\" keyword not found"); return result; }/*from w w w.jav a 2 s . c o m*/ List<Object> yamlPolicies = (List<Object>) policies; for (Object yamlPolicyObj : yamlPolicies) { if (yamlPolicyObj == null) { continue; } LinkedHashMap<String, Object> yamlPolicy = (LinkedHashMap<String, Object>) yamlPolicyObj; for (Object polObj : yamlPolicy.values()) { if (polObj == null) { continue; } LinkedHashMap<String, Object> yamlPolicyDef = (LinkedHashMap<String, Object>) polObj; Policy policy = new Policy(); Object name = yamlPolicyDef.get("id"); if (name == null) { log.warn("Policy object found, but no \"id\" field"); continue; } String policyName = (String) name; policy.setName(policyName); Object serviceProxiesObj = yamlPolicyDef.get("serviceProxy"); if (serviceProxiesObj == null) { log.warn("Policy object found, but no service proxies specified "); continue; } List<String> serviceProxyNames = (List<String>) serviceProxiesObj; for (String sp : serviceProxyNames) { policy.getServiceProxies().add(sp); } //Optionals like rateLimit/quota etc. follow Object rateLimitObj = yamlPolicyDef.get("rateLimit"); if (rateLimitObj != null) { LinkedHashMap<String, Object> rateLimitData = (LinkedHashMap<String, Object>) rateLimitObj; RateLimit rateLimit = new RateLimit(); int requests = -1; Object requestsObj = rateLimitData.get("requests"); if (requestsObj == null) { log.warn("RateLimit object found, but request field is empty"); requests = RateLimit.REQUESTS_DEFAULT; } else { try { requests = Integer.parseInt((String) requestsObj); } catch (NumberFormatException ignored) { // there is an entry, but its not a number ( maybe empty quotes ) requests = RateLimit.REQUESTS_DEFAULT; } } int interval = -1; Object intervalObj = rateLimitData.get("interval"); if (intervalObj == null) { log.warn( "RateLimit object found, but interval field is empty. Setting default: \" + RateLimit.INTERVAL_DEFAULT"); interval = RateLimit.INTERVAL_DEFAULT; } else { try { interval = Integer.parseInt((String) intervalObj); } catch (NumberFormatException ignored) { interval = RateLimit.INTERVAL_DEFAULT; } } rateLimit.setRequests(requests); rateLimit.setInterval(interval); policy.setRateLimit(rateLimit); } Object quotaObj = yamlPolicyDef.get("quota"); if (quotaObj != null) { LinkedHashMap<String, Object> quota = (LinkedHashMap<String, Object>) quotaObj; Object quotaSizeObj = quota.get("size"); long quotaNumber = 0; String quotaSymbolString = ""; if (quotaSizeObj == null) { log.warn("Quota object found, but size field is empty"); quotaNumber = Quota.SIZE_DEFAULT; } else { try { String quotaString = (String) quotaSizeObj; quotaNumber = ((Number) NumberFormat.getInstance().parse(quotaString)).intValue(); quotaSymbolString = quotaString.replaceFirst(Long.toString(quotaNumber), "") .toLowerCase(); } catch (ParseException ignored) { quotaNumber = Quota.SIZE_DEFAULT; } } if (quotaSymbolString.length() > 0) { char quotaSymbol = quotaSymbolString.charAt(0); switch (quotaSymbol) { case 'g': quotaNumber *= 1024; case 'm': quotaNumber *= 1024; case 'k': quotaNumber *= 1024; case 'b': default: } } Object quotaIntervalObj = quota.get("interval"); int quotaInterval = 0; if (quotaIntervalObj == null) { log.warn("Quota object found, but interval field is empty"); quotaInterval = Quota.INTERVAL_DEFAULT; } else { try { quotaInterval = Integer.parseInt((String) quotaIntervalObj); } catch (NumberFormatException ignored) { quotaInterval = Quota.INTERVAL_DEFAULT; } } Quota q = new Quota(); q.setSize(quotaNumber); q.setInterval(quotaInterval); policy.setQuota(q); } result.put(policyName, policy); } } return result; }
From source file:gr.demokritos.iit.cru.creativity.reasoning.semantic.WebMiner.java
public static String WebMiner(String seed, int difficulty, String language, boolean compactForm) throws ClassNotFoundException, SQLException, IOException, InstantiationException, IllegalAccessException {//from www. j a v a 2 s. c o m Gson gson = new Gson(); Connect c = new Connect(language); RandomWordGenerator r = new RandomWordGenerator(c); String randomPhrase = r.selectRandomWord(seed, difficulty).replace(",", " "); InfoSummarization inf = new InfoSummarization(c); LinkedHashMap<String, Double> TagCloud = new LinkedHashMap<String, Double>(); Set<String> pages = new HashSet<String>(); ArrayList<String> urls = new ArrayList<String>(); ArrayList<String> urls_temp = new ArrayList<String>(); if (language.equalsIgnoreCase("en")) { if (randomPhrase.length() == 0) { randomPhrase = seed; } String bingAppId = c.getBingAppId(); BingCrawler bc = new BingCrawler(bingAppId, language); urls_temp = bc.crawl(randomPhrase); int url_loop = 0; while ((url_loop < 5) && (url_loop < urls_temp.size())) { urls.add(urls_temp.get(url_loop)); url_loop++; } } else if (language.equalsIgnoreCase("el")) { String bingAppId = c.getBingAppId(); BingCrawler bc = new BingCrawler(bingAppId, language); urls_temp = bc.crawl(randomPhrase); int url_loop = 0; while ((url_loop < 5) && (url_loop < urls_temp.size())) { urls.add(urls_temp.get(url_loop)); url_loop++; } } else if (language.equalsIgnoreCase("de")) {//keep only the first word of the random phrase for search if (randomPhrase.length() == 0) { randomPhrase = seed; } urls_temp = HTMLUtilities.linkExtractor( "http://www.fragfinn.de/kinderliste/suche?start=0&query=" + randomPhrase.split(" ")[0], "UTF-8", 0); for (String url : urls_temp) { urls.add(StringEscapeUtils.unescapeHtml4(url)); if (urls.size() == 5) { break; } } } String delims = "[{} .,;?!():\"]+"; String[] words = randomPhrase.split(","); String[] user_keywords = seed.split(delims); if (urls.size() > 0) { ExecutorService threadPool = Executors.newFixedThreadPool(urls.size()); for (String url : urls) { threadPool.submit(new HTMLPages(url, pages, language)); //stopWordSet, tokensHashMap,language)); // threadPool.submit(HTMLTokenizer()); } threadPool.shutdown(); while (!threadPool.isTerminated()) { } LinkedHashMap<ArrayList<String>, Double> temp = inf.TopTermsBing(pages, compactForm); HashMap<String, Double> temp2 = new HashMap<String, Double>(); for (ArrayList<String> stems : temp.keySet()) { for (int j = 0; j < stems.size(); j++) { String s = stems.get(j).split("\\{")[0]; s = s.replace(",", " "); s = s.trim(); boolean wordnet = true; //if term is not one of the initial random phrase for (int i = 0; i < words.length; i++) { if (s.equalsIgnoreCase(words[i])) { wordnet = false; } } //and if it 's not in the initial words of user for (int i = 0; i < user_keywords.length; i++) { if (s.equalsIgnoreCase(user_keywords[i])) { wordnet = false; } } //in german or greek, ignore english words from search english words if (language.equalsIgnoreCase("de") || language.equalsIgnoreCase("el")) { if (c.getWn().getCommonPos(s) != null) { continue; } } //return it with its stem's weight if (wordnet) { //for every stem, put each of its corresponding terms to tagCloud with the stem's tf temp2.put(stems.get(j), temp.get(stems)); } } } TagCloud = inf.sortHashMapByValues(temp2); threadPool.shutdownNow(); } String json = gson.toJson(TagCloud); c.CloseConnection(); return json; }
From source file:eu.hydrologis.jgrass.charting.impl.JGrassXYTimeLineChart.java
/** * A line chart creator basing on series made up two values per row. More series, independing * one from the other are supported.//from w w w .j a v a 2 s.co m * * @param chartValues - a hashmap containing as keys the name of the series and as values the * double[][] representing the data. In this case the x value is assumed to ge a date. * Important: the data matrix has to be passed as two rows (not two columns) */ public JGrassXYTimeLineChart(LinkedHashMap<String, double[][]> chartValues, Class<RegularTimePeriod> timeClass) { try { chartSeries = new TimeSeries[chartValues.size()]; constructor = timeClass.getConstructor(Date.class); final Iterator<String> it = chartValues.keySet().iterator(); int count = 0; while (it.hasNext()) { final String key = it.next(); final double[][] values = chartValues.get(key); chartSeries[count] = new TimeSeries(key, timeClass); for (int i = 0; i < values[0].length; i++) { // important: the data matrix has to be passed as two rows (not // two columns) double val = values[1][i]; if (isNovalue(val)) continue; chartSeries[count].add(constructor.newInstance(new Date((long) values[0][i])), val); } count++; } lineDataset = new TimeSeriesCollection(); for (int i = 0; i < chartSeries.length; i++) { lineDataset.addSeries(chartSeries[i]); } lineDataset.setXPosition(TimePeriodAnchor.MIDDLE); } catch (Exception e) { ChartPlugin.log("ChartPlugin problem", e); //$NON-NLS-1$ } }
From source file:net.sf.jasperreports.engine.fill.DelayedFillActions.java
protected void doCollectElementEvaluations(JRPrintPage page, List<JRPrintElement> elements, final ElementEvaluationsCollector collector, boolean clearEmpty) { FillPageKey pageKey = new FillPageKey(page); for (Map.Entry<JREvaluationTime, LinkedHashMap<FillPageKey, LinkedMap<Object, EvaluationBoundAction>>> boundMapEntry : actionsMap .entrySet()) {/*from www . j av a 2 s .co m*/ final JREvaluationTime evaluationTime = boundMapEntry.getKey(); LinkedHashMap<FillPageKey, LinkedMap<Object, EvaluationBoundAction>> map = boundMapEntry.getValue(); synchronized (map) { final LinkedMap<Object, EvaluationBoundAction> actionsMap = map.get(pageKey); if (actionsMap != null && !actionsMap.isEmpty()) { // FIXME optimize for pages with a single virtual block // create a deep element visitor PrintElementVisitor<Void> visitor = new UniformPrintElementVisitor<Void>(true) { @Override protected void visitElement(JRPrintElement element, Void arg) { // remove the action from the map because we're saving it as part of the page. // ugly cast but acceptable for now. ElementEvaluationAction action = (ElementEvaluationAction) actionsMap.remove(element); if (action != null) { if (log.isDebugEnabled()) { log.debug(id + " collecting evaluation " + evaluationTime + " of element " + element); } collector.collect(element, action.element, evaluationTime); } } }; for (JRPrintElement element : elements) { element.accept(visitor, null); } if (clearEmpty && actionsMap.isEmpty()) { map.remove(pageKey); } } } } }
From source file:eu.hydrologis.jgrass.charting.impl.JGrassXYTimeBarChart.java
/** * A line chart creator basing on series made up two values per row. More series, independing * one from the other are supported.//from ww w . ja v a 2 s. c om * * @param chartValues - a hashmap containing as keys the name of the series and as values the * double[][] representing the data. In this case the x value is assumed to ge a date. * Important: the data matrix has to be passed as two rows (not two columns) * @param barWidth TODO */ public JGrassXYTimeBarChart(LinkedHashMap<String, double[][]> chartValues, Class<RegularTimePeriod> timeClass, double barWidth) { try { chartSeries = new TimeSeries[chartValues.size()]; constructor = timeClass.getConstructor(Date.class); final Iterator<String> it = chartValues.keySet().iterator(); int count = 0; while (it.hasNext()) { final String key = it.next(); final double[][] values = chartValues.get(key); chartSeries[count] = new TimeSeries(key, timeClass); for (int i = 0; i < values[0].length; i++) { // important: the data matrix has to be passed as two rows (not // two columns) chartSeries[count].add(constructor.newInstance(new Date((long) values[0][i])), values[1][i]); } count++; } lineDataset = new TimeSeriesCollection(); for (int i = 0; i < chartSeries.length; i++) { lineDataset.addSeries(chartSeries[i]); } lineDataset.setXPosition(TimePeriodAnchor.MIDDLE); if (barWidth != -1) dataset = new XYBarDataset(lineDataset, barWidth); } catch (Exception e) { ChartPlugin.log("ChartPlugin", e); //$NON-NLS-1$ } }
From source file:eu.hydrologis.jgrass.formeditor.utils.FormContentSaveHelper.java
/** * Converts the {@link AWidget widgets} to XML and dumps it to file. * /* w w w . ja va 2 s .com*/ * @throws Exception */ public void save() throws Exception { // divide by tab LinkedHashMap<String, List<AWidget>> widgets4Tab = new LinkedHashMap<String, List<AWidget>>(); List<String> orderedNamesList = new ArrayList<String>(); List<Integer> yPositionsList = new ArrayList<Integer>(); for (AWidget widget : widgets) { String tab = widget.getTab(); List<AWidget> list = widgets4Tab.get(tab); if (list == null) { list = new ArrayList<AWidget>(); widgets4Tab.put(tab, list); int y = widget.getLocation().y; if (orderedNamesList.size() == 0) { orderedNamesList.add(tab); yPositionsList.add(y); } else { int index = 0; while (index < orderedNamesList.size() && y > yPositionsList.get(index)) { index++; } orderedNamesList.add(index, tab); yPositionsList.add(index, y); } } list.add(widget); // also clean them widget.setMarked(false); } String[] fieldNamesArrays = FormEditor.getFieldNamesArrays(); AForm form = new AForm(); float tabIndex = 0; for (String tabName : orderedNamesList) { List<AWidget> widgetList = widgets4Tab.get(tabName); ATab tab = new ATab(); tab.name = tabName; tab.text = tabName; tab.order = tabIndex++; tab.layoutConstraints = "insets 20 20 20 20, fill"; // tab.colConstraints = "[left][fill][left][fill]"; List<ACheckBox> checkboxs = tab.checkbox; List<AComboBox> comboboxs = tab.combobox; List<ALabel> labels = tab.label; List<ARadioButton> radiobuttons = tab.radiobutton; List<ASeparator> separators = tab.separator; List<ATextArea> textareas = tab.textarea; List<ATextField> textfields = tab.textfield; // now define who is on which row float widgetIndex = 0f; for (AWidget widget : widgetList) { int[] rowBounds = widget.getRowBounds(); int[] colBounds = widget.getColBounds(); int widgetStartRow = rowBounds[0]; int widgetEndRow = rowBounds[1]; int widgetStartCol = colBounds[0]; int widgetEndCol = colBounds[1]; if (widget instanceof LabelWidget) { LabelWidget labelWidget = (LabelWidget) widget; ALabel label = new ALabel(); label.name = labelWidget.getName(); label.text = labelWidget.getText(); label.order = widgetIndex++; label.constraints = "cell " + widgetStartCol + " " + widgetStartRow + " " + (widgetEndCol - widgetStartCol + 1) + " " + (widgetEndRow - widgetStartRow + 1) + ", growx"; labels.add(label); } else if (widget instanceof TextFieldWidget) { TextFieldWidget textFieldWidget = (TextFieldWidget) widget; ATextField textField = new ATextField(); textField.name = textFieldWidget.getName(); // textField.text = textFieldWidget.getTextValue(); textField.defaultText = textFieldWidget.getDefaultValue(); textField.fieldName = fieldNamesArrays[textFieldWidget.getFieldnameValue()]; textField.valueType = Constants.TEXT_TYPES[textFieldWidget.getTypeValue()]; textField.order = widgetIndex++; textField.constraints = "cell " + widgetStartCol + " " + widgetStartRow + " " + (widgetEndCol - widgetStartCol + 1) + " " + (widgetEndRow - widgetStartRow + 1) + ", growx"; textfields.add(textField); } else if (widget instanceof TextAreaWidget) { TextAreaWidget textAreaWidget = (TextAreaWidget) widget; ATextArea textArea = new ATextArea(); textArea.name = textAreaWidget.getName(); // textField.text = textFieldWidget.getTextValue(); textArea.defaultText = textAreaWidget.getDefaultValue(); textArea.fieldName = fieldNamesArrays[textAreaWidget.getFieldnameValue()]; textArea.order = widgetIndex++; textArea.constraints = "cell " + widgetStartCol + " " + widgetStartRow + " " + (widgetEndCol - widgetStartCol + 1) + " " + (widgetEndRow - widgetStartRow + 1) + ", growx, growy"; textareas.add(textArea); } else if (widget instanceof SeparatorWidget) { SeparatorWidget separatorWidget = (SeparatorWidget) widget; ASeparator separator = new ASeparator(); separator.name = separatorWidget.getName(); separator.order = widgetIndex++; separator.orientation = Constants.ORIENTATION_TYPES[separatorWidget.getTypeValue()]; separator.constraints = "cell " + widgetStartCol + " " + widgetStartRow + " " + (widgetEndCol - widgetStartCol + 1) + " " + (widgetEndRow - widgetStartRow + 1) + ", growx"; separators.add(separator); } else if (widget instanceof CheckBoxWidget) { CheckBoxWidget checkboxWidget = (CheckBoxWidget) widget; ACheckBox checkboxField = new ACheckBox(); checkboxField.name = checkboxWidget.getName(); checkboxField.fieldName = fieldNamesArrays[checkboxWidget.getFieldnameValue()]; checkboxField.defaultText = Constants.CHECKBOX_TYPES[checkboxWidget.getDefaultValue()]; checkboxField.order = widgetIndex++; checkboxField.constraints = "cell " + widgetStartCol + " " + widgetStartRow + " " + (widgetEndCol - widgetStartCol + 1) + " " + (widgetEndRow - widgetStartRow + 1) + ", growx"; checkboxs.add(checkboxField); } else if (widget instanceof RadioButtonWidget) { RadioButtonWidget radioButtonWidget = (RadioButtonWidget) widget; ARadioButton radioButton = new ARadioButton(); radioButton.name = radioButtonWidget.getName(); radioButton.defaultText = radioButtonWidget.getDefaultValue(); radioButton.fieldName = fieldNamesArrays[radioButtonWidget.getFieldnameValue()]; radioButton.order = widgetIndex++; radioButton.orientation = Constants.ORIENTATION_TYPES[radioButtonWidget.getTypeValue()]; radioButton.constraints = "cell " + widgetStartCol + " " + widgetStartRow + " " + (widgetEndCol - widgetStartCol + 1) + " " + (widgetEndRow - widgetStartRow + 1) + ", growx"; if (radioButton.item == null) { radioButton.item = new ArrayList<String>(); } String itemsValue = radioButtonWidget.getItemsValue(); String[] itemsSplit = itemsValue.split(ITEMS_SEPARATOR); for (String item : itemsSplit) { radioButton.item.add(item.trim()); } radiobuttons.add(radioButton); } else if (widget instanceof ComboBoxWidget) { ComboBoxWidget comboBoxWidget = (ComboBoxWidget) widget; AComboBox comboBox = new AComboBox(); comboBox.name = comboBoxWidget.getName(); comboBox.defaultText = comboBoxWidget.getDefaultValue(); comboBox.fieldName = fieldNamesArrays[comboBoxWidget.getFieldnameValue()]; comboBox.order = widgetIndex++; comboBox.constraints = "cell " + widgetStartCol + " " + widgetStartRow + " " + (widgetEndCol - widgetStartCol + 1) + " " + (widgetEndRow - widgetStartRow + 1) + ", growx"; if (comboBox.item == null) { comboBox.item = new ArrayList<String>(); } String itemsValue = comboBoxWidget.getItemsValue(); /* * now this could be a string or a file path where to get the * items from */ if (itemsValue.startsWith("file:")) { if (itemsValue.endsWith(";y")) { comboBox.item.add(itemsValue); } else { String[] split = itemsValue.split(";"); String path = split[0].replaceFirst("file:", ""); int guiNameColumn = -1; try { guiNameColumn = Integer.parseInt(split[1]); } catch (Exception e) { } int attributeValueColumn = -1; try { attributeValueColumn = Integer.parseInt(split[2]); } catch (Exception e) { } String sep = split[3]; File itemsFile = new File(path); List readLines = FileUtils.readLines(itemsFile); for (Object line : readLines) { if (line instanceof String) { String lineStr = (String) line; String[] lineSplit = lineStr.split(sep); String finalString = ""; if (guiNameColumn >= 0) { finalString = finalString + lineSplit[guiNameColumn].trim() + ","; } finalString = finalString + lineSplit[attributeValueColumn].trim(); comboBox.item.add(finalString); } } } } else { String[] itemsSplit = itemsValue.split(ITEMS_SEPARATOR); for (String item : itemsSplit) { comboBox.item.add(item.trim()); } } comboboxs.add(comboBox); } } form.tab.add(tab); } Utilities.writeXML(form, file); }