List of usage examples for org.dom4j Element getTextTrim
String getTextTrim();
From source file:pt.webdetails.cda.dataaccess.AbstractDataAccess.java
License:Open Source License
private void parseOptions(final Element element) { id = element.attributeValue("id"); final Element nameElement = (Element) element.selectSingleNode("./Name"); if (nameElement != null) { name = nameElement.getTextTrim(); }// w ww. j a v a 2s. com if (element.attributeValue("access") != null && element.attributeValue("access").equals("private")) { access = DataAccessEnums.ACCESS_TYPE.PRIVATE; } if (element.attributeValue("cache") != null && element.attributeValue("cache").equals("true")) { cacheEnabled = true; } if (element.attribute("cacheDuration") != null && !element.attribute("cacheDuration").toString().equals("")) { cacheDuration = Integer.parseInt(element.attributeValue("cacheDuration")); } // Parse parameters @SuppressWarnings("unchecked") final List<Element> parameterNodes = element.selectNodes("Parameters/Parameter"); for (final Element p : parameterNodes) { parameters.add(new Parameter(p)); } // Parse outputs @SuppressWarnings("unchecked") final List<Element> outputNodes = element.selectNodes("Output"); for (final Element outputNode : outputNodes) { ArrayList<Integer> myOutputs = new ArrayList<Integer>(); if (outputNode != null) { int localId = 1; if (outputNode.attribute("id") != null && !outputNode.attribute("id").toString().equals("")) { // if parseInt fails an exception will be thrown and the cda file will not be accepted localId = Integer.parseInt(outputNode.attributeValue("id")); } else { // if an output has not a defined or empty id then it will have key = 1 localId = 1; } try { outputMode.put(localId, OutputMode.valueOf(outputNode.attributeValue("mode").toUpperCase())); } catch (Exception e) { // if there are any errors, go back to the default outputMode.put(localId, OutputMode.INCLUDE); } final String[] indexes = outputNode.attributeValue("indexes").split(","); for (final String index : indexes) { myOutputs.add(Integer.parseInt(index)); } outputs.put(localId, myOutputs); } } // Parse Columns @SuppressWarnings("unchecked") final List<Element> columnNodes = element.selectNodes("Columns/*"); for (final Element p : columnNodes) { columnDefinitions.add(new ColumnDefinition(p)); } // Build the columnDefinitionIndexMap final ArrayList<ColumnDefinition> cols = getColumns(); for (final ColumnDefinition columnDefinition : cols) { columnDefinitionIndexMap.put(columnDefinition.getIndex(), columnDefinition); } }
From source file:pt.webdetails.cte.CteSettings.java
License:Open Source License
protected List<String> initBlacklistedFileExtensions() { List<String> blacklistedFileExtensions = new ArrayList<String>(); List<Element> xmlElements = getSettingsXmlSection(Constants.SETTINGS_XPATH_BLACKLISTED_FILE_EXTENSIONS); if (xmlElements != null) { for (Element xmlElement : xmlElements) { String value = StringUtils.strip(xmlElement.getTextTrim()); if (StringUtils.isEmpty(value)) { logger.error("Invalid empty file extension. Skipping.."); continue; }/*w w w. jav a 2 s.c o m*/ blacklistedFileExtensions.add(value); } } return blacklistedFileExtensions; }
From source file:pt.webdetails.cte.CteSettings.java
License:Open Source License
protected List<String> initBlacklistedFolders() { List<String> blacklistedFolders = new ArrayList<String>(); List<Element> xmlElements = getSettingsXmlSection(Constants.SETTINGS_XPATH_BLACKLISTED_FOLDERS); if (xmlElements != null) { for (Element xmlElement : xmlElements) { String value = StringUtils.strip(xmlElement.getTextTrim()); if (StringUtils.isEmpty(value)) { logger.error("Invalid empty path. Skipping.."); continue; }//from w w w . j ava2 s . co m blacklistedFolders.add(value); } } return blacklistedFolders; }
From source file:pt.webdetails.cte.CteSettings.java
License:Open Source License
protected List<String> initBlacklistedPlugins() { List<String> blacklistedPlugins = new ArrayList<String>(); List<Element> xmlElements = getSettingsXmlSection(Constants.SETTINGS_XPATH_BLACKLISTED_PLUGINS); if (xmlElements != null) { for (Element xmlElement : xmlElements) { String value = StringUtils.strip(xmlElement.getTextTrim()); if (StringUtils.isEmpty(value)) { logger.error("Invalid empty plugin id. Skipping.."); continue; }/*from w w w . j a va 2 s.com*/ blacklistedPlugins.add(value); } } return blacklistedPlugins; }
From source file:revaligner.service.FileAligner.java
public void createAlignedXML_auto(String prjid) throws Exception { System.out.println("creating aligned xml with nbAligner...."); this.alignedfile = (this.prjfolder + File.separator + "rev_aligned.xml"); this.reformattedtargetmapfile = (this.prjfolder + File.separator + "target_reformatted" + File.separator + ".mp"); HashMap<String, String> srcidmap = new HashMap(); this.nbalignerfolder = (this.prjfolder + File.separator + "nbaligner"); if (!new File(this.nbalignerfolder).exists()) { new File(this.nbalignerfolder).mkdir(); }// ww w . j ava 2 s .co m FileUtils.cleanDirectory(new File(this.nbalignerfolder)); String nbsourcefolder = this.nbalignerfolder + File.separator + this.sourcelanguage; new File(nbsourcefolder).mkdir(); org.dom4j.Document nbsource = DocumentHelper.createDocument(); org.dom4j.Element root_src = nbsource.addElement("txml"); root_src.addAttribute("locale", this.sourcelanguage); root_src.addAttribute("version", "1.0"); root_src.addAttribute("segtype", "sentence"); org.dom4j.Element translatable_src = root_src.addElement("translatable"); translatable_src.addAttribute("blockId", "1"); String nbtargetfolder = this.nbalignerfolder + File.separator + this.targetlanguage; new File(nbtargetfolder).mkdir(); org.dom4j.Document nbtarget = DocumentHelper.createDocument(); org.dom4j.Element root_trg = nbtarget.addElement("txml"); root_trg.addAttribute("locale", this.targetlanguage); root_trg.addAttribute("version", "1.0"); root_trg.addAttribute("segtype", "sentence"); org.dom4j.Element translatable_trg = root_trg.addElement("translatable"); translatable_trg.addAttribute("blockId", "0"); if (new File(this.alignedfile).exists()) { new File(this.alignedfile).delete(); } SegmenterFactory factory = new SegmenterFactory(); Configuration segconfig = createConfigForSegmenter(false, this.sourcelanguage); Segmenter segmenter = factory.getSegmenter("trados", Locale.makeLocale(this.sourcelanguage), segconfig); org.dom4j.Document document = DocumentHelper.createDocument(); org.dom4j.Element root = document.addElement("alinger"); org.dom4j.Element head = root.addElement("head"); head.addAttribute("src_lang", this.sourcelanguage); head.addAttribute("trg_lang", this.targetlanguage); head.addAttribute("creator", this.creatorid); org.dom4j.Element aligned = root.addElement("aligned"); org.dom4j.Element orphans = root.addElement("orphans"); org.dom4j.Document document_source_formatted_nonSeg = XmlParser .parseXmlFile(this.reformattedsourcetxlf_nonSeg); org.dom4j.Element root_source_formatted_nonSeg = document_source_formatted_nonSeg.getRootElement(); List list_source_formatted_nonSeg = root_source_formatted_nonSeg.selectNodes("//*[name() = 'trans-unit']"); org.dom4j.Document document_target_nonSeg = XmlParser.parseXmlFile(this.reformattedtargettxlf_nonSeg); org.dom4j.Element root_target_nonSeg = document_target_nonSeg.getRootElement(); List list_target_nonSeg = root_target_nonSeg.selectNodes("//*[name() = 'trans-unit']"); org.dom4j.Document document_target_seg = XmlParser.parseXmlFile(this.reformattedtargettxlf_seg); org.dom4j.Element root_target_seg = document_target_seg.getRootElement(); List list_target_seg = root_target_seg.selectNodes("//*[name() = 'group'][@restype = 'x-paragraph']"); ExtractionSupportImpl extractionSupportImpl_src = new ExtractionSupportImpl( Locale.makeLocale(this.sourcelanguage), Locale.makeLocale(this.sourcelanguage)); Configuration config_src = new BaseConfiguration(); config_src.setProperty("extraction.tokens.extract", "all"); extractionSupportImpl_src.setConfiguration(config_src); ExtractionSupportImpl extractionSupportImpl_trg = new ExtractionSupportImpl( Locale.makeLocale(this.targetlanguage), Locale.makeLocale(this.targetlanguage)); Configuration config_trg = new BaseConfiguration(); config_trg.setProperty("extraction.tokens.extract", "all"); extractionSupportImpl_trg.setConfiguration(config_trg); boolean issrcfirsthf = true; boolean istrgfirsthf = true; int gcount = -1; int segmentId = 0; for (int i = 0; i < list_source_formatted_nonSeg.size(); i++) { org.dom4j.Element src_txlf = ((org.dom4j.Element) list_source_formatted_nonSeg.get(i)) .element("source"); String merged_text = getTxlfElementText_withFakeTC(src_txlf); if (extractionSupportImpl_src .isExtractable(merged_text.replace("&paradel;", "").replace("&parains;", ""))) { gcount++; org.dom4j.Element group = aligned.addElement("group"); group.addAttribute("id", Integer.toString(gcount)); merged_text = trimText(merged_text, true)[0]; org.dom4j.Element merged_src_text = group.addElement("text"); merged_src_text.setText(merged_text.replace("&paradel;", "").replace("&parains;", "")); String[] split_merged_text = merged_text.replaceAll("(&paradel;)+", "&paradel;") .replaceAll("^&paradel;", "").replaceAll("&paradel;$", "").split("&paradel;"); List<String> segmentsGroup = segmentStringWithRevs( merged_text.replaceAll("(&paradel;)+", "&paradel;").replace("&parains;", ""), this.sourcelanguage); List<List<String>> resegmentedGroup = new ArrayList(); resegmentedGroup.add(new ArrayList()); int idx = 0; String orgs; String[] newsegs; for (int s = 0; s < segmentsGroup.size(); s++) { orgs = (String) segmentsGroup.get(s); if (orgs.contains("&paradel;")) { newsegs = orgs.split("&paradel;"); for (int ss = 0; ss < newsegs.length; ss++) { String sss = newsegs[ss]; if (!sss.trim().equals("")) { ((List) resegmentedGroup.get(idx)).add(fixMissingTags(sss)); } if ((((List) resegmentedGroup.get(idx)).size() != 0) && (ss != newsegs.length - 1)) { resegmentedGroup.add(new ArrayList()); idx++; } } if (orgs.trim().endsWith("&paradel;")) { resegmentedGroup.add(new ArrayList()); idx++; } } else { ((List) resegmentedGroup.get(idx)).add(fixMissingTags(orgs)); } } if (split_merged_text.length > resegmentedGroup.size()) { System.out.println(i); System.out.println("merged_text: " + merged_text); for (String smt : split_merged_text) { System.out.println("split_merged_text: " + smt); } for (List<String> smts : resegmentedGroup) { System.out.println("resegmentedGroup: " + smts); } for (String smtss : segmentsGroup) { System.out.println("segmentedGroup: " + smtss); } } for (int j = 0; j < split_merged_text.length; j++) { if (!split_merged_text[j].replaceAll("<(/)*ins>|<(/)*del>", "").trim().equals("")) { split_merged_text[j] = fixMissingTags(split_merged_text[j]); Element unit = group.addElement("unit"); unit.addAttribute("id", Integer.toString(j)); unit.addAttribute("alignsegs", "false"); Element src = unit.addElement("src_para"); org.dom4j.Element src_text = src.addElement("text"); boolean isAddedPara = split_merged_text[j].contains("&parains;"); src.addAttribute("added", "" + isAddedPara); String[] trim_result = trimText(split_merged_text[j].replace("&parains;", ""), false); src.addAttribute("lefttrim", trim_result[1]); src.addAttribute("righttrim", trim_result[2]); split_merged_text[j] = trim_result[0]; int src_tctype_para = TrackChangeHelper.getTrackChangeType(split_merged_text[j]); src.addAttribute("tctype", TrackChangeType.getName(src_tctype_para)); String rejected_src = split_merged_text[j].replaceAll("(?s)<ins>.*?</ins>", "") .replace("<del>", "").replace("</del>", ""); if (!extractionSupportImpl_src.isExtractable(rejected_src)) { unit.addAttribute("locked", "true"); } else { unit.addAttribute("locked", "false"); } src_text.setText(split_merged_text[j]); org.dom4j.Element src_segs = src.addElement("segments"); List<String> segments = (List) resegmentedGroup.get(j); for (int z = 0; z < segments.size(); z++) { String segment_text = trimText((String) segments.get(z), false)[0]; org.dom4j.Element src_seg = src_segs.addElement("src_seg"); src_seg.addAttribute("id", Integer.toString(z)); src_seg.addAttribute("needreview", "false"); src_seg.addAttribute("ignored", "false"); int tctype_seg = TrackChangeHelper.getTrackChangeType(segment_text); src_seg.addAttribute("tctype", TrackChangeType.getName(tctype_seg)); String accepted_t = segment_text.replaceAll("(?s)<del>.*?</del>", "") .replace("<ins>", "").replace("</ins>", ""); src_seg.addAttribute("isExtractable", Boolean.toString(extractionSupportImpl_src.isExtractable(accepted_t))); String rejected_s = segment_text.replaceAll("(?s)<ins>.*?</ins>", "") .replace("<del>", "").replace("</del>", ""); if (!extractionSupportImpl_src.isExtractable(rejected_s)) { src_seg.addAttribute("locked", "true"); } else { src_seg.addAttribute("locked", "false"); org.dom4j.Element segment_src = translatable_src.addElement("segment"); segment_src.addAttribute("segmentId", Integer.toString(segmentId)); srcidmap.put(i + " - " + j + " - " + z, Integer.toString(segmentId)); segmentId++; segment_src.addElement("source").setText(rejected_s); } src_seg.setText(segment_text); } } } } } segmentId = 0; for (int i = 0; i < list_target_nonSeg.size(); i++) { org.dom4j.Element trg_txlf = ((org.dom4j.Element) list_target_nonSeg.get(i)).element("source"); String trg_formatted_text = getTxlfElementText_normal(trg_txlf); List<String> trgsegs = segmentStringWithRevs(trg_formatted_text, this.targetlanguage); for (int j = 0; j < trgsegs.size(); j++) { String trgseg = ((String) trgsegs.get(j)).trim().replaceAll("(\\s)+", " "); if (extractionSupportImpl_trg.isExtractable(trgseg)) { org.dom4j.Element segment_trg = translatable_trg.addElement("segment"); segment_trg.addAttribute("segmentId", Integer.toString(segmentId)); segmentId++; segment_trg.addElement("source").setText(trgseg); } } } OutputStreamWriter writer = new OutputStreamWriter( new BufferedOutputStream( new FileOutputStream(nbsourcefolder + File.separator + this.sourcelanguage + ".txml")), "UTF8"); nbsource.write(writer); writer.close(); writer = new OutputStreamWriter( new BufferedOutputStream( new FileOutputStream(nbtargetfolder + File.separator + this.targetlanguage + ".txml")), "UTF8"); nbtarget.write(writer); writer.close(); String pahtexe = "\\\\10.2.50.190\\AutoAlignerCLI\\AutoAlignerCLI.exe"; ProcessBuilder pb = new ProcessBuilder( new String[] { pahtexe, "-i", this.nbalignerfolder, "-o", this.nbalignerfolder, "-lang_pairs", this.sourcelanguage + "_" + this.targetlanguage, "-lang_detect", "normal", "-identicals", "-match_filenames", "-txml_or_xmx_output", "-docnames_output", "-disallow_src_merging" }); pb.redirectErrorStream(true); Process p = pb.start(); InputStreamReader isr = new InputStreamReader(p.getInputStream()); BufferedReader br = new BufferedReader(isr); boolean sentESTTime = false; boolean alignstart = false; String lineRead; while ((lineRead = br.readLine()) != null) { System.out.println(lineRead); if (lineRead.contains("Aligning...")) { alignstart = true; } else { if ((lineRead.contains("Estimated Time to Completion:")) && (alignstart)) { this.estimateNBAlignerCompTime = lineRead.replace("Estimated Time to Completion: ", "") .replace(" Minute(s)", ""); } if ((!this.estimateNBAlignerCompTime.equals("")) && (!sentESTTime)) { sentESTTime = true; try { int minutes = 200 + Integer.parseInt(this.estimateNBAlignerCompTime); setAlignProgress(prjid, minutes); this.estimateNBAlignerCompTime = ""; } catch (Exception ex) { ex.printStackTrace(); } } } } p.waitFor(); for (File file : new File(this.nbalignerfolder).listFiles()) { if (file.getName().endsWith(".zip")) { UnzipFile.UnZipIt(file.getAbsolutePath(), this.nbalignerfolder); } } String alignedtxml = ""; for (File file : new File(this.nbalignerfolder).listFiles()) { if (file.getName().endsWith(".txml")) { alignedtxml = file.getAbsolutePath(); } } if (alignedtxml.equals("")) { throw new Exception("file didn't aligned by nbaligner"); } HashMap<String, String[]> alignedtrgs = new HashMap(); List<String[]> missingtrgs = new ArrayList(); int src_idx = -1; org.dom4j.Document alignedtxmldoc = XmlParser.parseXmlFile(alignedtxml); org.dom4j.Element root_alignedtxmldoc = alignedtxmldoc.getRootElement(); for (int i = 0; i < root_alignedtxmldoc.elements("translatable").size(); i++) { org.dom4j.Element translatable = (org.dom4j.Element) root_alignedtxmldoc.elements("translatable") .get(i); for (int j = 0; j < translatable.elements("segment").size(); j++) { org.dom4j.Element segment = (org.dom4j.Element) translatable.elements("segment").get(j); org.dom4j.Element source = segment.element("source"); org.dom4j.Element target = segment.element("target"); if ((source != null) && (!source.getTextTrim().equals(""))) { src_idx++; if ((target != null) && (!target.getTextTrim().equals(""))) { String matchscore = target.attributeValue("score"); int trg_idx = Integer.parseInt(target.attributeValue("sent_no")); if (matchscore.equals("0")) { alignedtrgs.put(Integer.toString(src_idx), new String[] { target.getTextTrim(), "1", Integer.toString(trg_idx) }); } else if (target.attribute("original_segments_count") != null) { int merged_cnt = Integer.parseInt(target.attributeValue("original_segments_count")); String trg_idx_str = Integer.toString(trg_idx) + " - " + Integer.toString(trg_idx + merged_cnt - 1); alignedtrgs.put(Integer.toString(src_idx), new String[] { target.getTextTrim(), matchscore, trg_idx_str }); } else { alignedtrgs.put(Integer.toString(src_idx), new String[] { target.getTextTrim(), matchscore, Integer.toString(trg_idx) }); } } } else if ((target != null) && (!target.getTextTrim().equals(""))) { String matchscore = target.attributeValue("score"); int trg_idx = Integer.parseInt(target.attributeValue("sent_no")); missingtrgs.add(new String[] { target.getTextTrim(), Integer.toString(trg_idx) }); } } } int null_idx = 0; List<org.dom4j.Element> groups = aligned.elements("group"); for (int i = 0; i < groups.size(); i++) { org.dom4j.Element group = (org.dom4j.Element) groups.get(i); List<org.dom4j.Element> units = group.elements("unit"); for (int j = 0; j < units.size(); j++) { org.dom4j.Element unit = (org.dom4j.Element) units.get(j); org.dom4j.Element src_para = unit.element("src_para"); org.dom4j.Element src_para_segs = src_para.element("segments"); org.dom4j.Element trg_para = unit.addElement("trg_para"); org.dom4j.Element trg_para_segs = trg_para.addElement("segments"); List<org.dom4j.Element> src_segs = src_para_segs.elements("src_seg"); for (int z = 0; z < src_segs.size(); z++) { org.dom4j.Element src_seg = (org.dom4j.Element) src_segs.get(z); org.dom4j.Element trg_seg = trg_para_segs.addElement("trg_seg"); String mapid = Integer.toString(i) + " - " + Integer.toString(j) + " - " + Integer.toString(z); trg_seg.addAttribute("edited", "false"); String trgsegtext = ""; if (srcidmap.containsKey(mapid)) { String sourceidintxml = (String) srcidmap.get(mapid); if (alignedtrgs.containsKey(sourceidintxml)) { src_seg.addAttribute("locked", "true"); trgsegtext = ((String[]) alignedtrgs.get(sourceidintxml))[0]; String score = ((String[]) alignedtrgs.get(sourceidintxml))[1]; String targetidintxml = ((String[]) alignedtrgs.get(sourceidintxml))[2]; if (Integer.parseInt(score) < needreviewthreshhold) { src_seg.addAttribute("needreview", "true"); } trg_seg.addAttribute("id", targetidintxml); trg_seg.addAttribute("isExtractable", Boolean.toString(extractionSupportImpl_trg.isExtractable(trgsegtext))); } else { trg_seg.addAttribute("id", "n - " + null_idx); null_idx++; trg_seg.addAttribute("isExtractable", "false"); } } else { trg_seg.addAttribute("id", "n - " + null_idx); null_idx++; trg_seg.addAttribute("isExtractable", "false"); } trg_seg.setText(trgsegtext); } } } org.dom4j.Element orp_unit = orphans.addElement("unit"); orp_unit.addAttribute("id", "0"); org.dom4j.Element orp_trg_para = orp_unit.addElement("trg_para"); org.dom4j.Element orp_segments = orp_trg_para.addElement("segments"); for (int i = 0; i < missingtrgs.size(); i++) { String orptrgtext = ((String[]) missingtrgs.get(i))[0]; String orptrgid = ((String[]) missingtrgs.get(i))[1]; org.dom4j.Element orp_trg_seg = orp_segments.addElement("trg_seg"); orp_trg_seg.addAttribute("id", orptrgid); orp_trg_seg.addAttribute("edited", "false"); orp_trg_seg.addAttribute("isExtractable", Boolean.toString(extractionSupportImpl_trg.isExtractable(orptrgtext))); orp_trg_seg.setText(orptrgtext); } OutputStreamWriter oswriter = new OutputStreamWriter( new BufferedOutputStream(new FileOutputStream(this.alignedfile)), "UTF8"); document.write(oswriter); oswriter.close(); }
From source file:ru.apertum.qsystem.client.forms.FIndicatorBoard.java
License:Open Source License
private void loadPanel(Element params, RunningLabel label, QPanel panel) { if (!"1".equals(params.attributeValue(Uses.TAG_BOARD_VISIBLE_PANEL))) { return;//w w w.j a va 2s . co m } // label.setBackground(bgColor); // final Font font = new Font(getFontName(), label.getFont().getStyle(), Integer.parseInt(Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FONT_SIZE).get(0) .attributeValue(Uses.TAG_BOARD_VALUE))); label.setForeground( Color.decode("#" + (Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FONT_COLOR) .get(0).attributeValue(Uses.TAG_BOARD_VALUE)))); label.setFont(font); // ? final String filePath = Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FON_IMG).get(0) .attributeValue(Uses.TAG_BOARD_VALUE); File fp = new File(filePath); if (fp.exists()) { label.setBackgroundImage(filePath); } // String fileFractalXml = ""; if (Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FRACTAL).size() > 0) { fileFractalXml = Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FRACTAL).get(0) .attributeValue(Uses.TAG_BOARD_VALUE); } final File frX = new File(fileFractalXml); if (frX.exists()) { panel.removeAll(); panel.setLayout(new GridLayout(1, 1)); final FIndicatorBoard fi; try { fi = new FIndicatorBoard(new SAXReader(false).read(frX).getRootElement(), true, true); fi.loadConfig(); panel.add(fi.panelCommon); } catch (DocumentException ex) { System.err.println(ex); } } else { // final String filePathVid = Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_VIDEO_FILE) .get(0).attributeValue(Uses.TAG_BOARD_VALUE); File fv = new File(filePathVid); if (fv.exists()) { label.setVisible(false); panel.setVideoFileName(filePathVid); panel.startVideo(); } else // ? , ?? if ("1".equals(Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_SIMPLE_DATE).get(0) .attributeValue(Uses.TAG_BOARD_VALUE))) { label.setRunningText(""); label.setText(""); label.setShowTime(true); } else // ? if ("1".equals(Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_GRID_NEXT).get(0) .attributeValue(Uses.TAG_BOARD_VALUE))) { // label.setVerticalAlignment(1); label.setRunningText(""); label.setText("<HTML>" + "<table cellpadding='5' align='center' border='" + Uses.elementsByAttr(mainElement, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_GRID_NEXT_FRAME_BORDER).get(0).attributeValue(Uses.TAG_BOARD_VALUE) + "' bordercolor='0'>" + "<tr><td>" + "<p align=center>" + "<span style='font-size:" + Uses.elementsByAttr(mainElement, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FONT_SIZE_CAPTION) .get(0).attributeValue(Uses.TAG_BOARD_VALUE) + ".0pt;color:" + Uses.elementsByAttr(mainElement, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FONT_COLOR_CAPTION) .get(0).attributeValue(Uses.TAG_BOARD_VALUE) + ";'>" + nextGridCaption + "</span></p>" + "</td></tr>" + "<tr>" + "</table>"); nexts.add(label); el_nexts.put(label, params); } else { final String rt = Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_RUNNING_TEXT) .get(0).attributeValue(Uses.TAG_BOARD_VALUE).trim(); if (!"".equals(rt)) { label.setRunningText(rt); label.setText(""); label.setSpeedRunningText(Integer .parseInt(Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_SPEED_TEXT) .get(0).attributeValue(Uses.TAG_BOARD_VALUE))); label.start(); } else { // ? -? URL final String txt = params.getTextTrim(); Pattern replace = Pattern.compile(pattern); Matcher matcher = replace.matcher(txt); if (new File(txt).exists() || matcher.matches() || txt.contains("localhost") || txt.contains("127.0.0.1")) { panel.removeAll(); GridLayout gl = new GridLayout(1, 1); panel.setLayout(gl); BrowserFX bfx = new BrowserFX(); panel.add(bfx, BorderLayout.CENTER); //bfx.load(txt); bfx.load(Uses.prepareAbsolutPathForImg(txt)); } else { label.setText(Uses.prepareAbsolutPathForImg(txt)); label.setRunningText(""); } } // } ////?// } // }
From source file:ru.apertum.qsystem.common.Uses.java
License:Open Source License
/** * ? public static ArrayList elementsByAttr(...). * * @param list ?? ?//w ww . java2 s. c o m * @param el ? * @param text CData */ private static void getListCData(ArrayList list, Element el, String text) { if (text.equals(el.getTextTrim())) { list.add(el); } el.elements().stream().forEach((obj) -> { getListCData(list, (Element) obj, text); }); }
From source file:ru.runa.wf.logic.bot.updatepermission.UpdatePermissionsXmlParser.java
License:Open Source License
public static UpdatePermissionsSettings read(String configuration) { UpdatePermissionsSettings settings = new UpdatePermissionsSettings(); Document document = XmlUtils.parseWithXSDValidation(configuration, "update-permissions.xsd"); Element root = document.getRootElement(); List<Element> orgFunctionElements = root.element(ORGFUNCTIONS_ELEMENT_NAME) .elements(ORGFUNCTION_ELEMENT_NAME); for (Element element : orgFunctionElements) { settings.getSwimlaneInitializers().add(element.getTextTrim()); }//from w ww .j a v a 2s . c o m settings.setMethod(Method.valueOf(root.elementTextTrim(METHOD_ELEMENT_NAME))); List<Element> permissionElements = root.element(PERMISSIONS_ELEMENT_NAME).elements(PERMISSION_ELEMENT_NAME); for (Element element : permissionElements) { Permission p = Permission.valueOf(element.getTextTrim()); ApplicablePermissions.check(SecuredObjectType.PROCESS, p); settings.getPermissions().add(p); } Element conditionElement = root.element(CONDITION_ELEMENT_NAME); if (conditionElement != null) { settings.setCondition(conditionElement.attributeValue(CONDITION_VAR_NAME_ATTRIBUTE_NAME), conditionElement.attributeValue(CONDITION_VAR_VALUE_ATTRIBUTE_NAME)); } return settings; }
From source file:se.kb.oai.pmh.ErrorResponseException.java
License:Apache License
/** * Creates an <code>ErrorResponseException</code> with the returned error code and error message. * //from w w w.j a v a 2s . co m * @param error the <code><error></code> element */ public ErrorResponseException(Element error) { super(); this.code = error.attributeValue(ERROR_CODE_ATTR); this.message = error.getTextTrim(); }
From source file:se.kb.oai.pmh.ResumptionToken.java
License:Apache License
/** * Create a <code>ResumptionToken</code> from the <code><resumptionToken></code> element of a * response./*from ww w .ja v a2 s .com*/ * * @param element */ public ResumptionToken(Element element) { this.id = element.getTextTrim(); this.expirationDate = element.attributeValue("expirationDate"); this.completeListSize = -1; try { if (element.attributeValue("completeListSize") != null && !element.attributeValue("completeListSize").isEmpty()) { this.completeListSize = Integer.parseInt(element.attributeValue("completeListSize")); } } catch (NumberFormatException nfe) { this.completeListSize = -1; } }