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.archimatetool.templates.model.TemplateManager.java
License:Open Source License
public void saveUserTemplatesManifest() throws IOException { if (fUserTemplates == null || fUserTemplateGroups == null) { return;//from w ww. ja va2 s .co m } Document doc = new Document(); Element rootElement = new Element(XML_TEMPLATE_ELEMENT_MANIFEST); doc.setRootElement(rootElement); for (ITemplate template : fUserTemplates) { Element templateElement = new Element(XML_TEMPLATE_ELEMENT_TEMPLATE); rootElement.addContent(templateElement); templateElement.setAttribute(XML_TEMPLATE_ATTRIBUTE_TYPE, template.getType()); templateElement.setAttribute(XML_TEMPLATE_ATTRIBUTE_ID, template.getID()); templateElement.setAttribute(XML_TEMPLATE_ATTRIBUTE_FILE, template.getFile().getAbsolutePath()); } for (ITemplateGroup group : fUserTemplateGroups) { Element groupElement = new Element(XML_TEMPLATE_ELEMENT_GROUP); rootElement.addContent(groupElement); groupElement.setAttribute(XML_TEMPLATE_ATTRIBUTE_NAME, group.getName()); for (ITemplate template : group.getTemplates()) { Element templateRefElement = new Element(XML_TEMPLATE_ELEMENT_TEMPLATE_REF); groupElement.addContent(templateRefElement); templateRefElement.setAttribute(XML_TEMPLATE_ATTRIBUTE_REF, template.getID()); } } JDOMUtils.write2XMLFile(doc, getUserTemplatesManifestFile()); }
From source file:com.ardor3d.extension.model.collada.jdom.ColladaMeshUtils.java
License:Open Source License
/** * Extract our pipes from the given parent element. * /*from ww w. j a va2s . c o m*/ * @param inputsParent * @param pipesStore * the store for our pipes * @return the max offset of our pipes. */ private int extractPipes(final Element inputsParent, final LinkedList<ColladaInputPipe> pipesStore) { int maxOffset = 0; int texCount = 0; for (final Element input : inputsParent.getChildren("input")) { maxOffset = Math.max(maxOffset, _colladaDOMUtil.getAttributeIntValue(input, "offset", 0)); try { final Type type = Type.valueOf(input.getAttributeValue("semantic")); if (type == Type.VERTEX) { final Element vertexElement = _colladaDOMUtil .findTargetWithId(input.getAttributeValue("source")); for (final Element vertexInput : vertexElement.getChildren("input")) { vertexInput.setAttribute("offset", input.getAttributeValue("offset")); vertexInput.setAttribute("isVertexDefined", "true"); final ColladaInputPipe pipe = new ColladaInputPipe(_colladaDOMUtil, vertexInput); if (pipe.getType() == Type.TEXCOORD) { pipe.setTexCoord(texCount++); } pipesStore.add(pipe); } } else { final ColladaInputPipe pipe = new ColladaInputPipe(_colladaDOMUtil, input); if (pipe.getType() == Type.TEXCOORD) { pipe.setTexCoord(texCount++); } pipesStore.add(pipe); } } catch (final Exception ex) { logger.warning("Unknown input type: " + input.getAttributeValue("semantic")); continue; } } return maxOffset; }
From source file:com.astronomy.project.Project.java
/** * Save project as XML file/*from w w w . j a va 2s . co m*/ * @param file XML file * @throws FileNotFoundException File not found error * @throws IOException IO error * @throws NullPointerException Null pointer error */ public void toXML(File file) throws FileNotFoundException, IOException, NullPointerException { Element estudioElemento = new Element("estudio"); Document doc = new Document(estudioElemento); estudioElemento.setAttribute("nombre", name); Element aa = new Element("alineamientos"); estudioElemento.addContent(aa); for (int i = 0; i < data.size(); i++) { Alignment ali = (Alignment) data.get(i); aa.addContent(ali.getXMLElement()); } XMLOutputter xmlOutput = new XMLOutputter(); xmlOutput.setFormat(Format.getPrettyFormat()); FileOutputStream out = null; try { xmlOutput.output(doc, out = new FileOutputStream(file)); } finally { out.close(); } }
From source file:com.astronomy.project.ReferencePoint.java
/** * /*from w w w .j a v a2 s . c om*/ * @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.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * ? ?/*from w ww .j a v a 2 s . c o m*/ * * @param data * @return */ public static List<Element> setFileSummary(AnalyzeDefinition data) { List<Element> childs = new ArrayList<Element>(); if (data.getFileSummaryMap() != null) { Element child1 = new Element("table"); Element child2 = new Element("chart"); child2.setAttribute("title", MessageUtil.getMessage("pdf.message.chart.title.file_count")); Element childE1 = new Element("header"); Element childE2 = new Element("row"); Element childE3; child1.setAttribute("size", "4"); childE1.addContent( new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.extension"))); childE1.addContent( new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.file_count"))); childE1.addContent( new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.source_encoding"))); childE1.addContent( new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.target_encoding"))); for (FileType fileType : FileType.values()) { FileSummary summary = data.getFileSummaryMap().get(fileType); if (summary != null) { childE2.addContent(new Element("col").setText(fileType.toString())); childE2.addContent(new Element("col").setText(String.valueOf(summary.getFileCount()))); childE2.addContent(new Element("col").setText(summary.getSourceEncoding())); childE2.addContent(new Element("col").setText(summary.getTargetEncoding())); childE3 = new Element("data"); childE3.addContent(new Element("column").setText(fileType.toString())); childE3.addContent(new Element("value").setText(String.valueOf(summary.getFileCount()))); child2.addContent(childE3); } } child1.addContent(childE1); child1.addContent(childE2); childs.add(child1); childs.add(child2); } return childs; }
From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java
License:Apache License
/** * ?? ? ?//from w ww. j a v a2s. co m * (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 www. ja v a2s . 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. ja v a 2 s .c om*/ * * @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 w w w . j a v a2 s. co 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
/** * classes ?//w ww .jav a 2 s . c o m * * @param data * @param upload * @return */ public static List<Element> setClassData(AnalyzeDefinition data, Upload upload) { List<Element> childs = new ArrayList<Element>(); List<ClassAnalyze> dataList = data.getClassesConstList(); if (dataList.size() > 0) { Element child, childE1, childE2, col, text; for (ClassAnalyze comm : dataList) { text = new Element("text"); text.setText( MessageUtil.getMessage("pdf.message.class_summary.label.class_name") + comm.getClassName()); childs.add(text); child = new Element("table"); childE1 = new Element("header"); childE2 = new Element("row"); child.setAttribute("size", "2"); col = new Element("col"); col.setAttribute("width", "100"); childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.subject"))); col = new Element("col"); col.setAttribute("width", "300"); childE1.addContent(col.setText(MessageUtil.getMessage("pdf.message.table.header.contents"))); childE2.addContent(new Element("col") .setText(MessageUtil.getMessage("pdf.message.table.header.supper_class"))); childE2.addContent(new Element("col").setText(comm.getSuperClassesStr())); childE2.addContent( new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.interfaces"))); childE2.addContent(new Element("col").setText(comm.getInterfacesStr())); childE2.addContent(new Element("col") .setText(MessageUtil.getMessage("pdf.message.table.header.class_modifier"))); childE2.addContent(new Element("col").setText(comm.getClassModifier())); childE2.addContent( new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.final_class"))); childE2.addContent(new Element("col") .setText(comm.isFinalClass() == null ? "" : String.valueOf(comm.isFinalClass()))); childE2.addContent( new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.fields"))); childE2.addContent(new Element("col").setText(comm.getFiledListStr())); childE2.addContent( new Element("col").setText(MessageUtil.getMessage("pdf.message.table.header.methods"))); childE2.addContent(new Element("col").setText(comm.getMethodListStr())); child.addContent(childE1); child.addContent(childE2); childs.add(child); } } return childs; }