List of usage examples for org.jdom2 Element setText
public Element setText(final String text)
From source file:com.astronomy.project.ReferencePoint.java
/** * /*from w w w. java 2 s .c o m*/ * @return Reference point as XML element */ public Element getElementoXML() { Element raiz = new Element("lugar"); raiz.setAttribute("tipo", getType()); Element nombreElemento = new Element("nombre"); nombreElemento.setText(getName()); raiz.addContent(nombreElemento); if (getCoordinates() != null) { Element coordenadasElemento = new Element("coordenadas"); Element latitudElemento = new Element("latitud"); Element longitudElemento = new Element("longitud"); Element altitudElemento = new Element("altitud"); latitudElemento.setText(getCoordinates().getLatitude().toString()); longitudElemento.setText(getCoordinates().getLongitude().toString()); altitudElemento.setText(String.valueOf(getCoordinates().getElevation())); coordenadasElemento.addContent(latitudElemento); coordenadasElemento.addContent(longitudElemento); coordenadasElemento.addContent(altitudElemento); raiz.addContent(coordenadasElemento); } return raiz; }
From source file:com.astronomy.project.Tag.java
/** * //from ww w. j a v a 2s . c om * @return XML element for tag */ public Element getXMLElement() { Element raiz = new Element(name); raiz.setText(value.get()); return raiz; }
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * ?? ? ?/*from ww w .j a va2 s . com*/ * (type : servlet, ejb) * * @param data * @param type * @return */ public static List<Element> setPatternData(AnalyzeDefinition data, String type) { List<Element> childs = new ArrayList<Element>(); List<CommonAnalyze> dataList = new ArrayList<CommonAnalyze>(); if (type.equals("servlet")) dataList = data.getServletExtendsList(); else if (type.equals("ejb")) dataList = data.getEjbExtendsList(); if (dataList.size() > 0) { Element child = new Element("table"); Element childE1 = new Element("header"); Element childE2 = new Element("row"); child.setAttribute("size", "2"); Element col = new Element("col"); col.setAttribute("width", "150"); childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.file_name"))); col = new Element("col"); col.setAttribute("width", "300"); childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.location"))); for (CommonAnalyze comm : dataList) { childE2.addContent(new Element("col").setText(comm.getItem())); childE2.addContent(new Element("col").setText(comm.getLocation())); } child.addContent(childE1); child.addContent(childE2); childs.add(child); } return childs; }
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * ? ?/*from ww w. ja va2 s .c om*/ * (type : java, jsp, property, class) * * @param data * @param type * @return */ public static List<Element> setDependencyData(AnalyzeDefinition data, String type) { List<Element> childs = new ArrayList<Element>(); List<Dependency> dataList = new ArrayList<Dependency>(); if (type.equals("java")) dataList = data.getJavaDependencyList(); else if (type.equals("jsp")) dataList = data.getJspDependencyList(); else if (type.equals("property")) dataList = data.getPropertyDependencyList(); else if (type.equals("class")) dataList = data.getClassDependencyList(); if (dataList.size() > 0) { Element text; for (Dependency comm : dataList) { if (comm.getDependencyStrMap().entrySet().iterator().hasNext() || comm.getOthersStrMap().entrySet().iterator().hasNext()) { text = new Element("text"); text.setText(comm.getFileName()); text.setAttribute("padding", "23"); childs.add(text); Element box = new Element("box"); box.setAttribute("option", "other"); Iterator iterator = comm.getDependencyStrMap().entrySet().iterator(); StringBuffer buf = new StringBuffer(); while (iterator.hasNext()) { Entry entry = (Entry) iterator.next(); buf.append(entry.getKey() + " " + entry.getValue() + "\n"); } box.addContent( new Element("text").setAttribute("type", "default").setText(buf.toString() + "\n")); if (type.equals("java") || type.equals("jsp") || type.equals("property")) { iterator = comm.getOthersStrMap().entrySet().iterator(); if (iterator.hasNext()) { box.addContent(new Element("text").setAttribute("type", "red") .setText(" ?" + "\n")); buf = new StringBuffer(); while (iterator.hasNext()) { Entry entry = (Entry) iterator.next(); buf.append(entry.getKey() + " " + entry.getValue() + "\n"); } box.addContent(new Element("text").setAttribute("type", "default") .setText(buf.toString() + "\n")); } } childs.add(box); } } } return childs; }
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * JSP ? ? ?//from w w w. jav a 2s .c o m * * @param data * @param upload * @return */ public static List<Element> setJspAnalyzeData(AnalyzeDefinition data, Upload upload) { List<Element> childs = new ArrayList<Element>(); Map<String, Integer> dataMap = data.getJspDirectiveMap(); if (dataMap != null) { int jspFileCount = 0; if (data.getFileSummaryMap() != null) jspFileCount = ((FileSummary) data.getFileSummaryMap().get(FileType.JSP)).getFileCount(); childs.add(new Element("text").setText(MessageUtil.getMessage("pdf.message.jsp_summary.info.text", upload.getProjectNm(), String.valueOf(jspFileCount)))); Element child = new Element("table"); Element childE1 = new Element("header"); Element childE2 = new Element("row"); child.setAttribute("size", "2"); Element col = new Element("col"); col.setAttribute("width", "330"); childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.directive"))); col = new Element("col"); col.setAttribute("width", "70"); childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.file_count"))); Iterator iterator = dataMap.entrySet().iterator(); while (iterator.hasNext()) { Entry entry = (Entry) iterator.next(); childE2.addContent(new Element("col").setText(String.valueOf(entry.getKey()))); childE2.addContent(new Element("col").setText(String.valueOf(entry.getValue()))); } child.addContent(childE1); child.addContent(childE2); childs.add(child); } return childs; }
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * lib ?//from www .j a va2 s.c o m * (type : D - ? lib ) * * @param data * @param upload * @param type * @return */ public static List<Element> setLibData(AnalyzeDefinition data, Upload upload, String type) { List<Element> childs = new ArrayList<Element>(); List<String> dataList; if (type.equals("D")) dataList = data.getDeleteLibraryList(); else dataList = data.getLibraryList(); if (dataList.size() > 0) { Element child = new Element("table"); Element childE1 = new Element("header"); Element childE2 = new Element("row"); child.setAttribute("size", "1"); child.setAttribute("width", "150"); Element col = new Element("col"); childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.file_name"))); for (String text : dataList) { childE2.addContent(new Element("col").setText(text)); } child.addContent(childE1); child.addContent(childE2); childs.add(child); } return childs; }
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * ?? ? ? ? ?// www . j a v a2 s. com * * @param data * @param upload * @return */ public static List<Element> setApplicationListData(AnalyzeDefinition data, Upload upload) { List<Element> childs = new ArrayList<Element>(); List<CommonAnalyze> dataList = data.getDescripterList(); if (dataList.size() > 0) { Element child = new Element("table"); Element childE1 = new Element("header"); Element childE2 = new Element("row"); child.setAttribute("size", "2"); Element col = new Element("col"); col.setAttribute("width", "150"); childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.file_name"))); col = new Element("col"); col.setAttribute("width", "300"); childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.location"))); for (CommonAnalyze comm : dataList) { childE2.addContent(new Element("col").setText(comm.getItem())); childE2.addContent( new Element("col").setText(comm.getLocation() + File.separator + comm.getItem())); } child.addContent(childE1); child.addContent(childE2); childs.add(child); } return childs; }
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * ?? ? ? ?//from w w w. j av a 2 s . c om * * @param data * @param upload * @return */ public static List<Element> setApplicationData(AnalyzeDefinition data, Upload upload) { List<Element> childs = new ArrayList<Element>(); List<CommonAnalyze> dataList = data.getDescripterList(); if (dataList.size() > 0) { Element text; for (CommonAnalyze comm : dataList) { text = new Element("text"); text.setText(comm.getItem()); text.setAttribute("padding", "23"); childs.add(text); childs.add(new Element("box").setText(comm.getContents() + "\n")); } } return childs; }
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * ? ? /*from w w w. j a va2s.c o m*/ * * @param rootData * @param upload * @param type * @return * @throws Exception */ public static List<Element> setConvertEncodingData(AnalyzeDefinition data, Upload upload) { List<Element> childs = new ArrayList<Element>(); boolean viewFlag = false; for (Dependency dependency : data.getJavaDependencyList()) { Iterator iterator = dependency.getEncodingStrMap().entrySet().iterator(); if (iterator.hasNext()) { viewFlag = true; break; } } if (viewFlag) { Element section = new Element("section").setAttribute("title", "? ?"); section.addContent(new Element("text").setText( "? ? ? ? ? ?? ?? .")); Element text; for (Dependency comm : data.getJavaDependencyList()) { Iterator iterator = comm.getEncodingStrMap().entrySet().iterator(); if (iterator.hasNext()) { text = new Element("text"); text.setText(comm.getFileName()); text.setAttribute("padding", "23"); section.addContent(text); Element box = new Element("box"); StringBuffer buf = new StringBuffer(); while (iterator.hasNext()) { Entry entry = (Entry) iterator.next(); buf.append(entry.getKey() + " " + entry.getValue() + "\n"); } box.setText(buf.toString() + "\n"); section.addContent(box); } } childs.add(section); } return childs; }
From source file:com.bc.ceres.nbmgen.NbmGenTool.java
License:Open Source License
@Override public void process(CeresModuleProject project) throws JDOMException, IOException { System.out.println("Project [" + project.projectDir.getName() + "]:"); File originalPomFile = getFile(project.projectDir, CeresModuleProject.ORIGINAL_POM_XML); File pomFile = getFile(project.projectDir, CeresModuleProject.POM_XML); File manifestBaseFile = getFile(project.projectDir, "src", "main", "nbm", "manifest.mf"); Element projectElement = project.pomDocument.getRootElement(); Namespace ns = projectElement.getNamespace(); Element moduleElement = project.moduleDocument.getRootElement(); String moduleName = moduleElement.getChildTextTrim("name"); String moduleDescription = moduleElement.getChildTextNormalize("description"); String modulePackaging = moduleElement.getChildTextTrim("packaging"); String moduleNative = moduleElement.getChildTextTrim("native"); String moduleActivator = moduleElement.getChildTextTrim("activator"); String moduleChangelog = moduleElement.getChildTextTrim("changelog"); String moduleFunding = moduleElement.getChildTextTrim("funding"); String moduleVendor = moduleElement.getChildTextTrim("vendor"); String moduleContactAddress = moduleElement.getChildTextTrim("contactAddress"); String moduleCopyright = moduleElement.getChildTextTrim("copyright"); String moduleLicenseUrl = moduleElement.getChildTextTrim("licenseUrl"); // Not used anymore: //String moduleUrl = moduleElement.getChildTextTrim("url"); //String moduleAboutUrl = moduleElement.getChildTextTrim("aboutUrl"); if (moduleName != null) { Element nameElement = getOrAddElement(projectElement, "name", ns); nameElement.setText(moduleName); }/*from www . j a v a 2 s .co m*/ if (moduleDescription != null) { int nameIndex = projectElement.indexOf(projectElement.getChild("name")); Element descriptionElement = getOrAddElement(projectElement, "description", nameIndex + 1, ns); descriptionElement.setText(moduleDescription); } Element descriptionElement = getOrAddElement(projectElement, "packaging", ns); descriptionElement.setText("nbm"); Element urlElement = getOrAddElement(projectElement, "url", ns); urlElement.setText("https://sentinel.esa.int/web/sentinel/toolboxes"); Element buildElement = getOrAddElement(projectElement, "build", ns); Element pluginsElement = getOrAddElement(buildElement, "plugins", ns); Map<String, String> nbmConfiguration = new LinkedHashMap<>(); // moduleType is actually a constant which can be put it into the <pluginManagement-element of the parent nbmConfiguration.put("moduleType", "normal"); // licenseName/File should also be constant nbmConfiguration.put("licenseName", "GPL 3"); nbmConfiguration.put("licenseFile", "../LICENSE.html"); nbmConfiguration.put("cluster", cluster); nbmConfiguration.put("defaultCluster", cluster); nbmConfiguration.put("publicPackages", ""); nbmConfiguration.put("requiresRestart", "true"); addPluginElement(pluginsElement, "org.codehaus.mojo", "nbm-maven-plugin", nbmConfiguration, ns); Map<String, String> jarConfiguration = new LinkedHashMap<>(); jarConfiguration.put("useDefaultManifestFile", "true"); addPluginElement(pluginsElement, "org.apache.maven.plugins", "maven-jar-plugin", jarConfiguration, ns); StringBuilder longDescription = new StringBuilder(); longDescription.append(moduleDescription != null ? "<p>" + moduleDescription + "" : "") .append(descriptionEntry("Funding", moduleFunding)).append(descriptionEntry("Vendor", moduleVendor)) .append(descriptionEntry("Contact address", moduleContactAddress)) .append(descriptionEntry("Copyright", moduleCopyright)) .append(descriptionEntry("Vendor", moduleVendor)) .append(descriptionEntry("License", moduleLicenseUrl)) .append(descriptionEntry("Changelog", moduleChangelog)); Map<String, String> manifestContent = new LinkedHashMap<>(); manifestContent.put("Manifest-Version", "1.0"); manifestContent.put("AutoUpdate-Show-In-Client", "false"); manifestContent.put("AutoUpdate-Essential-Module", "true"); manifestContent.put("OpenIDE-Module-Java-Dependencies", "Java > 1.8"); manifestContent.put("OpenIDE-Module-Display-Category", "SNAP"); if (longDescription.length() > 0) { manifestContent.put("OpenIDE-Module-Long-Description", longDescription.toString()); } if (moduleActivator != null) { warnModuleDetail("Activator may be reimplemented for NB: " + moduleActivator + " (--> " + "consider using @OnStart, @OnStop, @OnShowing, or a ModuleInstall)"); manifestContent.put("OpenIDE-Module-Install", moduleActivator); } if (modulePackaging != null && !"jar".equals(modulePackaging)) { warnModuleDetail("Unsupported module packaging: " + modulePackaging + " (--> " + "provide a ModuleInstall that does the job on install/uninstall)"); } if (moduleNative != null && "true".equals(moduleNative)) { warnModuleDetail("Module contains native code: no auto-conversion possible (--> " + "follow NB instructions see http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/api.html#how-layer"); } if (!originalPomFile.exists()) { if (!dryRun) { Files.copy(project.pomFile.toPath(), originalPomFile.toPath()); } infoModuleDetail("Copied " + project.pomFile + " to " + originalPomFile); } if (!dryRun) { writeXml(pomFile, project.pomDocument); } if (pomFile.equals(project.pomFile)) { infoModuleDetail("Updated " + pomFile); } else { infoModuleDetail("Converted " + project.pomFile + " to " + pomFile); } //noinspection ResultOfMethodCallIgnored if (!dryRun) { manifestBaseFile.getParentFile().mkdirs(); writeManifest(manifestBaseFile, manifestContent); } infoModuleDetail("Written " + manifestBaseFile); }