List of usage examples for org.jdom2 Element setAttribute
public Element setAttribute(final String name, final String value)
This sets an attribute value for this element.
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * ?? ? ? ? ?/* w w w .j a v a2 s . c o m*/ * * @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
/** * ?? ? ? ?//w w w. j a v a 2 s .c o m * * @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
/** * ?? ?? EJB ?/* ww w .ja va2s . c om*/ * * @param data * @param upload * @return */ public static List<Element> setEjbApplicationData(AnalyzeDefinition data, Upload upload) { List<Element> childs = new ArrayList<Element>(); Iterator iterator = data.getEjbApplicationMap().entrySet().iterator(); while (iterator.hasNext()) { Entry entry = (Entry) iterator.next(); Element child, childE1, childE2, col; Element section = new Element("section"); section.setAttribute("title", String.valueOf(entry.getKey())); child = new Element("table"); childE1 = new Element("header"); childE2 = new Element("row"); child.setAttribute("size", "2"); col = new Element("col"); col.setAttribute("width", "150"); childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.contents"))); col = new Element("col"); col.setAttribute("width", "300"); childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.type"))); List<CommonAnalyze> dataList = (List<CommonAnalyze>) entry.getValue(); for (CommonAnalyze comm : dataList) { childE2.addContent(new Element("col").setText(comm.getItem())); childE2.addContent(new Element("col").setText(comm.getContents())); } child.addContent(childE1); child.addContent(childE2); section.addContent(new Element("text").setText(MessageUtil .getMessage("pdf.message.ejb_application.info.text", String.valueOf(entry.getKey())))); section.addContent(child); childs.add(section); } return childs; }
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * ?? Deployment Descriptor ?/*from w w w. j av a2s. co m*/ * (type : application, web, ejb) * * @param data * @param upload * @param type * @return */ public static List<Element> setTransXmlData(PDFMetadataDefinition data, Upload upload, String type) { List<Element> childs = new ArrayList<Element>(); List<EjbRecommend> dataList = null; List<String> transFileList = null; if (type.equals("application")) { dataList = data.getApplicationRecommendList(); transFileList = data.getAppTransFileList(); } else if (type.equals("web")) { dataList = data.getWebRecommendList(); transFileList = data.getWebTransFileList(); } else if (type.equals("ejb")) { dataList = data.getEjbRecommendList(); transFileList = data.getEjbTransFileList(); } Element section; for (EjbRecommend comm : dataList) { section = new Element("section"); if (comm.isTransFlag()) section.setAttribute("title", MessageUtil.getMessage("pdf.message.advice.title.trans_complete_file", comm.getItem())); else { section.setAttribute("title", MessageUtil.getMessage("pdf.message.advice.title.trans_target_file", comm.getItem())); section.addContent(new Element("textR").setText( MessageUtil.getMessage("pdf.message.advice.trans_target_file.text", comm.getItem()))); } section.addContent(new Element("text").setText(comm.getLocation() + File.separator + comm.getItem())); section.addContent(new Element("box").setText(comm.getContents())); childs.add(section); } childs.add(new Element("text").setAttribute("padding", "23") .setText(MessageUtil.getMessage("pdf.message.table.header.trans_target_file_list"))); if (transFileList.size() > 0) { Element child, childE1, childE2; child = new Element("table"); childE1 = new Element("header"); childE2 = new Element("row"); child.setAttribute("size", "1"); childE1.addContent( new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.file_name"))); for (String s : transFileList) { childE2.addContent(new Element("col").setText(s)); } child.addContent(childE1); child.addContent(childE2); childs.add(child); } return childs; }
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * ear Applications /*from w w w . j av a 2 s .c om*/ * (type : war - Web, jar - EJB) * * @param rootData * @param upload * @param type * @return * @throws Exception */ public static List<Element> setChildDeployData(PDFMetadataDefinition rootData, Upload upload, String type) throws Exception { List<Element> childs = new ArrayList<Element>(); List<Element> childs2; Iterator iterator = null; if (type.equals("war")) { iterator = rootData.getWarDefinitionMap().entrySet().iterator(); } else if (type.equals("jar")) { iterator = rootData.getJarDefinitionMap().entrySet().iterator(); } Element section; File childXml = null; while (iterator.hasNext()) { childs2 = new ArrayList<Element>(); Entry entry = (Entry) iterator.next(); AnalyzeDefinition data = (AnalyzeDefinition) entry.getValue(); if (type.equals("war")) { childXml = new File(PDFDocGenerator.class.getResource("/xml/war_application.xml").getFile()); } else if (type.equals("jar")) { childXml = new File(PDFDocGenerator.class.getResource("/xml/jar_application.xml").getFile()); } org.jdom2.Document chapterDoc = new SAXBuilder().build(childXml); Element root = chapterDoc.getRootElement(); section = new Element("section"); section.setAttribute("title", String.valueOf(entry.getKey())); for (Element e : root.getChildren()) { childs2.add(e.clone()); } for (Element e : childs2) { section.addContent(e); } setDynamicSection(section, data, upload); childs.add(section); } return childs; }
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * Maven Dependency ?/*from ww w .j av a 2 s .com*/ * * @param data * @param upload * @return */ public static List<Element> setMavenDependencyList(AnalyzeDefinition data, Upload upload) { List<Element> childs = new ArrayList<Element>(); Element child, childE1, childE2; if (data.getMavenProjectList().size() > 0) { Element section = new Element("section"); section.setAttribute("title", MessageUtil.getMessage("pdf.message.maven_dependency.title")); section.addContent(new Element("text") .setText(MessageUtil.getMessage("pdf.message.maven_dependency.text", upload.getProjectNm()))); Element cSection = new Element("section"); cSection.setAttribute("title", MessageUtil.getMessage("pdf.message.maven_dependency.pom.title")); cSection.addContent(new Element("box").setText(data.getMavenProjectList().get(0).getContents())); section.addContent(cSection); if (data.getMavenDependencyList().size() > 0) { cSection = new Element("section"); cSection.setAttribute("title", MessageUtil.getMessage("pdf.message.maven_dependency.lib.title")); cSection.addContent( new Element("text").setText(MessageUtil.getMessage("pdf.message.maven_dependency.lib.title") + MessageUtil.getMessage("pdf.message.maven_dependency.lib.ather_text"))); child = new Element("table"); childE1 = new Element("header"); childE2 = new Element("row"); child.setAttribute("size", "3"); childE1.addContent(new Element("col") .setText(MessageUtil.getMessage("pdf.message.table.header.trans_artifactId"))); childE1.addContent(new Element("col") .setText(MessageUtil.getMessage("pdf.message.table.header.trans_groupId"))); childE1.addContent(new Element("col") .setText(MessageUtil.getMessage("pdf.message.table.header.trans_version"))); for (MavenDependency comm : data.getMavenDependencyList()) { childE2.addContent(new Element("col").setText(comm.getArtifactId())); childE2.addContent(new Element("col").setText(comm.getGroupId())); childE2.addContent(new Element("col").setText(comm.getVersion())); } child.addContent(childE1); child.addContent(childE2); cSection.addContent(child); section.addContent(cSection); } if (data.getModifiedMavenDependencyList().size() > 0) { cSection = new Element("section"); cSection.setAttribute("title", MessageUtil.getMessage("pdf.message.maven_dependency.trans_lib.title")); cSection.addContent(new Element("text") .setText(MessageUtil.getMessage("pdf.message.maven_dependency.trans_lib.text"))); child = new Element("table"); childE1 = new Element("header"); childE2 = new Element("row"); child.setAttribute("size", "4"); childE1.addContent(new Element("col") .setText(MessageUtil.getMessage("pdf.message.table.header.trans_artifactId"))); childE1.addContent(new Element("col") .setText(MessageUtil.getMessage("pdf.message.table.header.trans_groupId"))); childE1.addContent(new Element("col") .setText(MessageUtil.getMessage("pdf.message.table.header.trans_version"))); childE1.addContent( new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.trans_scope"))); for (MavenDependency comm : data.getModifiedMavenDependencyList()) { childE2.addContent(new Element("col").setText(comm.getArtifactId())); childE2.addContent(new Element("col").setText(comm.getGroupId())); childE2.addContent(new Element("col").setText(comm.getVersion())); childE2.addContent(new Element("col").setText(comm.getScope())); } child.addContent(childE1); child.addContent(childE2); cSection.addContent(child); section.addContent(cSection); } if (data.getMavenProjectList().size() > 1) { cSection = new Element("section"); cSection.setAttribute("title", MessageUtil.getMessage("pdf.message.maven_dependency.trans_pom.title")); cSection.addContent(new Element("box").setText(data.getMavenProjectList().get(1).getContents())); section.addContent(cSection); } childs.add(section); } return childs; }
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * ? ? //from www. j a v a 2 s . co 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.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * ?? ? ?/*from w w w .j a va 2 s . c o m*/ * * @param data * @param upload * @return */ public static List<Element> setExceptionData(PDFMetadataDefinition data, Upload upload) { List<Element> childs = new ArrayList<Element>(); Element section; for (ExceptionInfo comm : data.getExceptionInfoList()) { section = new Element("section"); section.setAttribute("title", comm.getLocation()); if (comm.getComments() != null && comm.getComments().length() > 0) section.addContent(new Element("text").setText(comm.getComments())); section.addContent(new Element("box").setText(comm.getStackTrace())); childs.add(section); } return childs; }
From source file:com.c4om.autoconf.ulysses.extra.svrlmultipathinterpreter.SVRLMultipathInterpreterMain.java
License:Apache License
/** * This method performs the actual svrl interpretation process (which constitutes the objective solving process). * @param svrlDocument the SVRL document (i.e. the objective description) * @return the svrl interpreter report (i.e. the objective solution) * @throws JDOMException if there are XML problems * @throws IOException if there are I/O problems. *//*w ww . j a va 2s.co m*/ public Document interpret(Document svrlDocument) throws JDOMException, IOException { Element resultRootElement = new Element("report", AutoconfXMLConstants.NAMESPACE_SVRL_INTERPETER_REPORT); Document result = new Document(resultRootElement); List<String> pathsListRepeated = getPathsFromDocument(svrlDocument); PathGroupsGenerator pathGroupsGenerator = new PathGroupsGenerator(); List<PathGroup> pathGroups = pathGroupsGenerator.getPathGroups(pathsListRepeated); PartialNodeGenerator partialNodeGenerator = new PartialNodeGenerator(this.xpathNamespaces, this.pathToConfiguration, this.pathToMetamodel, this.metamodelAttributesPrefix); for (PathGroup pathGroup : pathGroups) { Element currentDiscrepancyElement = new Element("discrepancy", AutoconfXMLConstants.NAMESPACE_SVRL_INTERPETER_REPORT); Element currentInterestingPathsElement = new Element("interestingPaths", AutoconfXMLConstants.NAMESPACE_SVRL_INTERPETER_REPORT); // '/.[text()=something]' tokens should not be used to look for elements at the metamodel and/or search paths, as text DOES NOT identify elements according to our convention. String fixedBasePath = pathGroup.getBasePath().replaceAll("\\]/\\.\\[(?<bracketContent>[^\\]]+)\\]$", "]"); currentInterestingPathsElement.setAttribute("search-path", "doc('" + pathGroup.getDocumentPath() + "')" + fixedBasePath); currentDiscrepancyElement.addContent(currentInterestingPathsElement); Element suggestedPartialNodeElement = new Element("suggestedPartialNode", AutoconfXMLConstants.NAMESPACE_SVRL_INTERPETER_REPORT); currentDiscrepancyElement.addContent(suggestedPartialNodeElement); Element partialNode = partialNodeGenerator.generatePartialNode(pathGroup); suggestedPartialNodeElement.addContent(partialNode); File metamodelDocFile = new File(pathGroup.getDocumentPath()); if (!metamodelDocFile.isAbsolute()) { metamodelDocFile = new File(this.pathToMetamodel, pathGroup.getDocumentPath()); } List<Element> metamodelSuggestedNodeList; try { Document metamodelDoc = documentCache.get(metamodelDocFile.getAbsolutePath()); if (metamodelDoc == null) { metamodelDoc = loadJDOMDocumentFromFile(metamodelDocFile); documentCache.put(metamodelDocFile.getAbsolutePath(), metamodelDoc); } metamodelSuggestedNodeList = performJAXENXPath(fixedBasePath, metamodelDoc); } catch (IOException e) { metamodelSuggestedNodeList = Collections.emptyList(); } Element metamodelSuggestionsElement = new Element("metamodelSuggestions", AutoconfXMLConstants.NAMESPACE_SVRL_INTERPETER_REPORT); for (Element metamodelSuggestedNode : metamodelSuggestedNodeList) { metamodelSuggestionsElement.addContent(metamodelSuggestedNode.clone()); } currentDiscrepancyElement.addContent(metamodelSuggestionsElement); resultRootElement.addContent(currentDiscrepancyElement); } return result; }
From source file:com.cats.version.VersionCfgParseAndSave.java
License:Apache License
public boolean saveVersionInfo(List<VersionInfo> infos, String fullPath) { try {//from www.ja v a2s. c om Document doc = new Document(); Element root = new Element("software-group"); for (VersionInfo info : infos) { Element softEle = new Element("software"); softEle.setAttribute("name", info.getAppName()); Element versionCodeEle = new Element("latest-version-code"); Element versionNameEle = new Element("latest-version"); Element versionPathEle = new Element("latest-version-abspath"); Element startupNameEle = new Element("latest-version-startup"); versionCodeEle.setText(String.valueOf(info.getVersionCode())); versionNameEle.setText(info.getVersion()); versionPathEle.setText(info.getPath()); startupNameEle.setText(info.getStartupName()); softEle.addContent(versionCodeEle); softEle.addContent(versionNameEle); softEle.addContent(versionPathEle); softEle.addContent(startupNameEle); List<VersionInfoDetail> details = info.getDetails(); if (null != details) { Element detailEles = new Element("latest-version-detail"); for (VersionInfoDetail verDetail : details) { Element itemElem = new Element("item"); itemElem.setAttribute("name", verDetail.getTitle()); List<String> detailList = verDetail.getDetail(); for (String detailInfo : detailList) { Element detailEle = new Element("detail"); detailEle.setText(detailInfo); itemElem.addContent(detailEle); } detailEles.addContent(itemElem); } softEle.addContent(detailEles); } List<String> ignoreFiles = info.getIgnoreFiles(); if (ignoreFiles != null) { Element ignoreEles = new Element("ignore-files"); for (String ignoreInfo : ignoreFiles) { Element ignoreItemEle = new Element("item"); ignoreItemEle.setText(ignoreInfo); ignoreEles.addContent(ignoreItemEle); } softEle.addContent(ignoreEles); } root.addContent(softEle); } doc.setRootElement(root); //Save to xml file XMLOutputter xmlOut = null; FileOutputStream fos = null; try { fos = new FileOutputStream(fullPath); xmlOut = new XMLOutputter(Format.getPrettyFormat()); xmlOut.output(doc, fos); } catch (Exception e) { e.printStackTrace(); } finally { if (null != fos) { try { fos.close(); } catch (Exception e) { e.printStackTrace(); } } } } catch (Exception e) { e.printStackTrace(); return false; } return true; }