Here are the examples of the java api class org.jdom.Element taken from open source projects.
1. GeneralSettings#writeExternal()
Project: consulo
File: GeneralSettings.java
File: GeneralSettings.java
@Override public void writeExternal(Element parentNode) { if (myBrowserPath != null) { Element element = new Element(ELEMENT_OPTION); element.setAttribute(ATTRIBUTE_NAME, OPTION_BROWSER_PATH); element.setAttribute(ATTRIBUTE_VALUE, myBrowserPath); parentNode.addContent(element); } Element optionElement = new Element(ELEMENT_OPTION); optionElement.setAttribute(ATTRIBUTE_NAME, OPTION_LAST_TIP); optionElement.setAttribute(ATTRIBUTE_VALUE, Integer.toString(myLastTip)); parentNode.addContent(optionElement); optionElement = new Element(ELEMENT_OPTION); optionElement.setAttribute(ATTRIBUTE_NAME, OPTION_SHOW_TIPS_ON_STARTUP); optionElement.setAttribute(ATTRIBUTE_VALUE, Boolean.toString(myShowTipsOnStartup)); parentNode.addContent(optionElement); optionElement = new Element(ELEMENT_OPTION); optionElement.setAttribute(ATTRIBUTE_NAME, OPTION_SHOW_OCCUPIED_MEMORY); optionElement.setAttribute(ATTRIBUTE_VALUE, Boolean.toString(myShowOccupiedMemory)); parentNode.addContent(optionElement); optionElement = new Element(ELEMENT_OPTION); optionElement.setAttribute(ATTRIBUTE_NAME, OPTION_REOPEN_LAST_PROJECT); optionElement.setAttribute(ATTRIBUTE_VALUE, Boolean.toString(myReopenLastProject)); parentNode.addContent(optionElement); optionElement = new Element(ELEMENT_OPTION); optionElement.setAttribute(ATTRIBUTE_NAME, OPTION_AUTO_SYNC_FILES); optionElement.setAttribute(ATTRIBUTE_VALUE, Boolean.toString(mySyncOnFrameActivation)); parentNode.addContent(optionElement); optionElement = new Element(ELEMENT_OPTION); optionElement.setAttribute(ATTRIBUTE_NAME, OPTION_AUTO_SAVE_FILES); optionElement.setAttribute(ATTRIBUTE_VALUE, Boolean.toString(mySaveOnFrameDeactivation)); parentNode.addContent(optionElement); optionElement = new Element(ELEMENT_OPTION); optionElement.setAttribute(ATTRIBUTE_NAME, OPTION_AUTO_SAVE_IF_INACTIVE); optionElement.setAttribute(ATTRIBUTE_VALUE, (myAutoSaveIfInactive ? Boolean.TRUE : Boolean.FALSE).toString()); parentNode.addContent(optionElement); optionElement = new Element(ELEMENT_OPTION); optionElement.setAttribute(ATTRIBUTE_NAME, OPTION_INACTIVE_TIMEOUT); optionElement.setAttribute(ATTRIBUTE_VALUE, Integer.toString(myInactiveTimeout)); parentNode.addContent(optionElement); optionElement = new Element(ELEMENT_OPTION); optionElement.setAttribute(ATTRIBUTE_NAME, OPTION_USE_SAFE_WRITE); optionElement.setAttribute(ATTRIBUTE_VALUE, (myUseSafeWrite ? Boolean.TRUE : Boolean.FALSE).toString()); parentNode.addContent(optionElement); optionElement = new Element(ELEMENT_OPTION); optionElement.setAttribute(ATTRIBUTE_NAME, OPTION_USE_DEFAULT_BROWSER); optionElement.setAttribute(ATTRIBUTE_VALUE, Boolean.toString(myUseDefaultBrowser)); parentNode.addContent(optionElement); optionElement = new Element(ELEMENT_OPTION); optionElement.setAttribute(ATTRIBUTE_NAME, OPTION_CONFIRM_EXTRACT_FILES); optionElement.setAttribute(ATTRIBUTE_VALUE, Boolean.toString(myConfirmExtractFiles)); parentNode.addContent(optionElement); optionElement = new Element(ELEMENT_OPTION); optionElement.setAttribute(ATTRIBUTE_NAME, OPTION_SEARCH_IN_BACKGROUND); optionElement.setAttribute(ATTRIBUTE_VALUE, Boolean.toString(mySearchInBackground)); parentNode.addContent(optionElement); optionElement = new Element(ELEMENT_OPTION); optionElement.setAttribute(ATTRIBUTE_NAME, OPTION_CONFIRM_EXIT); optionElement.setAttribute(ATTRIBUTE_VALUE, Boolean.toString(myConfirmExit)); parentNode.addContent(optionElement); optionElement = new Element(ELEMENT_OPTION); optionElement.setAttribute(ATTRIBUTE_NAME, OPTION_CONFIRM_OPEN_NEW_PROJECT); optionElement.setAttribute(ATTRIBUTE_VALUE, Integer.toString(myConfirmOpenNewProject)); parentNode.addContent(optionElement); if (myLastProjectLocation != null) { optionElement = new Element(ELEMENT_OPTION); optionElement.setAttribute(ATTRIBUTE_NAME, OPTION_LAST_PROJECT_LOCATION); optionElement.setAttribute(ATTRIBUTE_VALUE, myLastProjectLocation); parentNode.addContent(optionElement); } }
2. MarkdownGlobalSettings#getState()
Project: idea-markdown
File: MarkdownGlobalSettings.java
File: MarkdownGlobalSettings.java
/** * Get the settings state as a DOM element. * * @return an ready to serialize DOM {@link Element}. * @see {@link #loadState(org.jdom.Element)} */ public Element getState() { final Element element = new Element("MarkdownSettings"); element.setAttribute("parsingTimeout", Integer.toString(parsingTimeout)); element.setAttribute("smarts", Boolean.toString(smarts)); element.setAttribute("quotes", Boolean.toString(quotes)); element.setAttribute("abbreviations", Boolean.toString(abbreviations)); element.setAttribute("hardWraps", Boolean.toString(hardWraps)); element.setAttribute("autoLinks", Boolean.toString(autoLinks)); element.setAttribute("wikiLinks", Boolean.toString(wikiLinks)); element.setAttribute("tables", Boolean.toString(tables)); element.setAttribute("definitions", Boolean.toString(definitions)); element.setAttribute("fencedCodeBlocks", Boolean.toString(fencedCodeBlocks)); element.setAttribute("suppressHTMLBlocks", Boolean.toString(suppressHTMLBlocks)); element.setAttribute("suppressInlineHTML", Boolean.toString(suppressInlineHTML)); element.setAttribute("strikethrough", Boolean.toString(strikethrough)); return element; }
3. Browser#asXml()
Project: jsunit
File: Browser.java
File: Browser.java
public Element asXml() { Element browserElement = new Element(BROWSER); Element fullFileNameElement = new Element(FULL_FILE_NAME); fullFileNameElement.setText(getFullFileName()); browserElement.addContent(fullFileNameElement); Element idElement = new Element(ID); idElement.setText(String.valueOf(getId())); browserElement.addContent(idElement); Element displayNameElement = new Element("displayName"); displayNameElement.setText(getDisplayName()); browserElement.addContent(displayNameElement); Element logoElement = new Element("logoPath"); logoElement.setText(getLogoPath()); browserElement.addContent(logoElement); return browserElement; }
4. PathMacrosCollectorTest#testCollectMacros()
Project: intellij-community
File: PathMacrosCollectorTest.java
File: PathMacrosCollectorTest.java
public void testCollectMacros() { Element root = new Element("root"); root.addContent(new Text("$MACro1$ some text $macro2$ other text $MACRo3$")); root.addContent(new Text("$macro4$ some text")); root.addContent(new Text("some text$macro5$")); root.addContent(new Text("file:$mac_ro6$")); root.addContent(new Text("jar://$macr.o7$ ")); root.addContent(new Text("$mac-ro8$ ")); root.addContent(new Text("$$$ ")); root.addContent(new Text("$c:\\a\\b\\c$ ")); root.addContent(new Text("$Revision 1.23$")); root.addContent(new Text("file://$root$/some/path/just$file$name.txt")); final Set<String> macros = PathMacrosCollector.getMacroNames(root, null, new PathMacrosImpl()); UsefulTestCase.assertSameElements(macros, "MACro1", "macro4", "mac_ro6", "macr.o7", "mac-ro8", "root"); }
5. GerritSettings#getState()
Project: gerrit-intellij-plugin
File: GerritSettings.java
File: GerritSettings.java
public Element getState() { final Element element = new Element(GERRIT_SETTINGS_TAG); element.setAttribute(LOGIN, (getLogin() != null ? getLogin() : "")); element.setAttribute(HOST, (getHost() != null ? getHost() : "")); element.setAttribute(LIST_ALL_CHANGES, "" + getListAllChanges()); element.setAttribute(AUTOMATIC_REFRESH, "" + getAutomaticRefresh()); element.setAttribute(REFRESH_TIMEOUT, "" + getRefreshTimeout()); element.setAttribute(REVIEW_NOTIFICATIONS, "" + getReviewNotifications()); element.setAttribute(PUSH_TO_GERRIT, "" + getPushToGerrit()); element.setAttribute(SHOW_CHANGE_NUMBER_COLUMN, "" + getShowChangeNumberColumn()); element.setAttribute(SHOW_CHANGE_ID_COLUMN, "" + getShowChangeIdColumn()); return element; }
6. PathMacrosCollectorTest#testCollectMacros()
Project: consulo
File: PathMacrosCollectorTest.java
File: PathMacrosCollectorTest.java
public void testCollectMacros() { Element root = new Element("root"); root.addContent(new Text("$MACro1$ some text $macro2$ other text $MACRo3$")); root.addContent(new Text("$macro4$ some text")); root.addContent(new Text("some text$macro5$")); root.addContent(new Text("file:$mac_ro6$")); root.addContent(new Text("jar://$macr.o7$ ")); root.addContent(new Text("$mac-ro8$ ")); root.addContent(new Text("$$$ ")); root.addContent(new Text("$c:\\a\\b\\c$ ")); root.addContent(new Text("$Revision 1.23$")); final Set<String> macros = PathMacrosService.getInstance().getMacroNames(root, null, new PathMacrosImpl()); assertEquals(5, macros.size()); assertTrue(macros.contains("MACro1")); assertTrue(macros.contains("macro4")); assertTrue(macros.contains("mac_ro6")); assertTrue(macros.contains("macr.o7")); assertTrue(macros.contains("mac-ro8")); }
7. TodoView#getState()
Project: consulo
File: TodoView.java
File: TodoView.java
@Override public Element getState() { Element element = new Element("TodoView"); if (myContentManager != null) { // all panel were constructed Content content = myContentManager.getSelectedContent(); element.setAttribute(ATTRIBUTE_SELECTED_INDEX, Integer.toString(myContentManager.getIndexOfContent(content))); } Element selectedFileElement = new Element(ELEMENT_TODO_PANEL); selectedFileElement.setAttribute(ATTRIBUTE_ID, VALUE_SELECTED_FILE); myCurrentPanelSettings.writeExternal(selectedFileElement); element.addContent(selectedFileElement); Element allElement = new Element(ELEMENT_TODO_PANEL); allElement.setAttribute(ATTRIBUTE_ID, VALUE_ALL); myAllPanelSettings.writeExternal(allElement); element.addContent(allElement); Element changeListElement = new Element(ELEMENT_TODO_PANEL); changeListElement.setAttribute(ATTRIBUTE_ID, VALUE_DEFAULT_CHANGELIST); myChangeListTodosPanelSettings.writeExternal(changeListElement); element.addContent(changeListElement); return element; }
8. SLAEventBean#getStatusEvent()
Project: oozie
File: SLAEventBean.java
File: SLAEventBean.java
private Element getStatusEvent(String tag) { Element eStat = new Element(tag); eStat.addContent(createATagElement("sequence-id", String.valueOf(getEvent_id()))); Element e = new Element("status"); e.addContent(createATagElement("sla-id", getSlaId())); e.addContent(createATagElement("status-timestamp", getDateString(getStatusTimestamp()))); e.addContent(createATagElement("job-status", getJobStatus().toString())); e.addContent(createATagElement("job-data", getJobData())); eStat.addContent(e); return eStat; }
9. Commander#getState()
Project: intellij-community
File: Commander.java
File: Commander.java
@Override public Element getState() { Element element = new Element("commander"); if (myLeftPanel == null || myRightPanel == null) { return element; } PsiDocumentManager.getInstance(myProject).commitAllDocuments(); Element e = new Element(ELEMENT_LEFTPANEL); element.addContent(e); writePanel(myLeftPanel, e); e = new Element(ELEMENT_RIGHTPANEL); element.addContent(e); writePanel(myRightPanel, e); e = new Element(ELEMENT_SPLITTER); element.addContent(e); e.setAttribute(ATTRIBUTE_PROPORTION, Float.toString(mySplitter.getProportion())); if (!MOVE_FOCUS) { e = new Element(ELEMENT_OPTION); element.addContent(e); //noinspection HardCodedStringLiteral e.setAttribute(ATTRIBUTE_MOVE_FOCUS, "false"); } return element; }
10. FormatInfoPrinter#createSpacingElement()
Project: consulo
File: FormatInfoPrinter.java
File: FormatInfoPrinter.java
private Element createSpacingElement(final Spacing spacing) { final Element result = new Element("Spacing"); final SpacingImpl impl = ((SpacingImpl) spacing); result.setAttribute("keepBlankLines", String.valueOf(impl.getKeepBlankLines())); result.setAttribute("keepLineBreaks", String.valueOf(impl.shouldKeepLineFeeds())); result.setAttribute("minspaces", String.valueOf(impl.getMinSpaces())); result.setAttribute("maxspaces", String.valueOf(impl.getMaxSpaces())); result.setAttribute("minlinefeeds", String.valueOf(impl.getMinLineFeeds())); result.setAttribute("readOnly", String.valueOf(impl.isReadOnly())); result.setAttribute("safe", String.valueOf(impl.isSafe())); return result; }
11. MartServiceXMLHandler#datasetToElement()
Project: incubator-taverna-plugin-bioinformatics
File: MartServiceXMLHandler.java
File: MartServiceXMLHandler.java
/** * Converts a <code>MartDataset</code> to an XML element. * * @param dataset * the <code>MartDataset</code> to serialize * @param namespace * the <code>Namespace</code> to use when constructing the * <code>Element</code> * @return an XML serialization of the <code>MartDataset</code> */ public static Element datasetToElement(MartDataset dataset, Namespace namespace) { Element element = new Element(MART_DATASET_ELEMENT, namespace); element.setAttribute(DISPLAY_NAME_ATTRIBUTE, dataset.getDisplayName()); element.setAttribute(NAME_ATTRIBUTE, dataset.getName()); element.setAttribute(TYPE_ATTRIBUTE, dataset.getType()); element.setAttribute(INITIAL_BATCH_SIZE_ATTRIBUTE, String.valueOf(dataset.getInitialBatchSize())); element.setAttribute(MAXIMUM_BATCH_SIZE_ATTRIBUTE, String.valueOf(dataset.getMaximumBatchSize())); element.setAttribute(VISIBLE_ATTRIBUTE, String.valueOf(dataset.isVisible())); if (dataset.getInterface() != null) { element.setAttribute(INTERFACE_ATTRIBUTE, dataset.getInterface()); } if (dataset.getModified() != null) { element.setAttribute(MODIFIED_ATTRIBUTE, dataset.getModified()); } element.addContent(locationToElement(dataset.getMartURLLocation(), namespace)); return element; }
12. FormatInfoPrinter#createSpacingElement()
Project: intellij-community
File: FormatInfoPrinter.java
File: FormatInfoPrinter.java
private Element createSpacingElement(final Spacing spacing) { final Element result = new Element("Spacing"); final SpacingImpl impl = ((SpacingImpl) spacing); result.setAttribute("keepBlankLines", String.valueOf(impl.getKeepBlankLines())); result.setAttribute("keepLineBreaks", String.valueOf(impl.shouldKeepLineFeeds())); result.setAttribute("minspaces", String.valueOf(impl.getMinSpaces())); result.setAttribute("maxspaces", String.valueOf(impl.getMaxSpaces())); result.setAttribute("minlinefeeds", String.valueOf(impl.getMinLineFeeds())); result.setAttribute("readOnly", String.valueOf(impl.isReadOnly())); result.setAttribute("safe", String.valueOf(impl.isSafe())); return result; }
13. ProjectStatus#ccTrayXmlElement()
Project: gocd
File: ProjectStatus.java
File: ProjectStatus.java
public Element ccTrayXmlElement(String fullContextPath) { Element element = new Element("Project"); element.setAttribute("name", name); element.setAttribute("activity", activity); element.setAttribute("lastBuildStatus", lastBuildStatus); element.setAttribute("lastBuildLabel", lastBuildLabel); element.setAttribute("lastBuildTime", DateUtils.formatIso8601ForCCTray(lastBuildTime)); element.setAttribute("webUrl", fullContextPath + "/" + webUrl); if (!breakers.isEmpty()) { addBreakers(element); } return element; }
14. XMLUtilities#createMobyDataWrapper()
Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
File: XMLUtilities.java
public static Element createMobyDataWrapper(String queryID, Element serviceNotes) throws MobyException { Element e = null; if (serviceNotes != null) e = (Element) serviceNotes.clone(); Element MOBY = new Element("MOBY", MOBY_NS); Element mobyContent = new Element("mobyContent", MOBY_NS); if (e != null) mobyContent.addContent(e.detach()); Element mobyData = new Element("mobyData", MOBY_NS); mobyData.setAttribute("queryID", queryID, MOBY_NS); MOBY.addContent(mobyContent); mobyContent.addContent(mobyData); return MOBY; }
15. XMLUtilities#renameSimple()
Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
File: XMLUtilities.java
/** * * @param oldName * @param newName * @param type * @param element * @return * @throws MobyException */ public static Element renameSimple(String newName, String type, Element element) throws MobyException { Element e = (Element) element.clone(); Element mobyData = extractMobyData(e); String queryID = getQueryID(e); Element serviceNotes = getServiceNotes(e); Element simple = mobyData.getChild("Simple"); if (simple == null) simple = mobyData.getChild("Simple", MOBY_NS); if (simple == null) { return e; } simple.removeAttribute("articleName"); simple.removeAttribute("articleName", MOBY_NS); simple.setAttribute("articleName", newName, MOBY_NS); return createMobyDataElementWrapper(simple, queryID, serviceNotes); }
16. ClusterMapper#mapServer()
Project: voldemort
File: ClusterMapper.java
File: ClusterMapper.java
private Element mapServer(Node node, boolean displayZones) { Element server = new Element(SERVER_ELMT); server.addContent(new Element(SERVER_ID_ELMT).setText(Integer.toString(node.getId()))); server.addContent(new Element(HOST_ELMT).setText(node.getHost())); server.addContent(new Element(HTTP_PORT_ELMT).setText(Integer.toString(node.getHttpPort()))); server.addContent(new Element(SOCKET_PORT_ELMT).setText(Integer.toString(node.getSocketPort()))); server.addContent(new Element(ADMIN_PORT_ELMT).setText(Integer.toString(node.getAdminPort()))); String serverPartitionsText = StringUtils.join(node.getPartitionIds().toArray(), ", "); server.addContent(new Element(SERVER_PARTITIONS_ELMT).setText(serverPartitionsText)); if (displayZones) server.addContent(new Element(ZONE_ID_ELMT).setText(Integer.toString(node.getZoneId()))); return server; }
17. ExternalizablePropertyTest#testReadList()
Project: consulo
File: ExternalizablePropertyTest.java
File: ExternalizablePropertyTest.java
public void testReadList() throws InvalidDataException { Element containerElement = new Element("xxx"); Element listElement = new Element("list"); containerElement.addContent(listElement); listElement.addContent(new Element("unknown")); listElement.addContent(new Element("item")); listElement.addContent(new Element("unknown")); myContainer.registerProperty(PROPERTY, "item", EXTERNALIZER); myContainer.readExternal(containerElement); List<MockJDOMExternalizable> list = PROPERTY.get(myContainer); assertEquals(1, list.size()); }
18. FilterInfo#writeExternal()
Project: consulo
File: FilterInfo.java
File: FilterInfo.java
@Override public void writeExternal(Element filterElement) { Element option = new Element(ELEMENT_OPTION); filterElement.addContent(option); option.setAttribute(ATTRIBUTE_NAME, FILTER_NAME); if (myName != null) { option.setAttribute(ATTRIBUTE_VALUE, myName); } option = new Element(ELEMENT_OPTION); filterElement.addContent(option); option.setAttribute(ATTRIBUTE_NAME, FILTER_DESCRIPTION); if (myDescription != null) { option.setAttribute(ATTRIBUTE_VALUE, myDescription); } option = new Element(ELEMENT_OPTION); filterElement.addContent(option); option.setAttribute(ATTRIBUTE_NAME, FILTER_REGEXP); if (myRegExp != null) { option.setAttribute(ATTRIBUTE_VALUE, myRegExp); } }
19. ExternalizablePropertyTest#testReadList()
Project: intellij-community
File: ExternalizablePropertyTest.java
File: ExternalizablePropertyTest.java
public void testReadList() throws InvalidDataException { Element containerElement = new Element("xxx"); Element listElement = new Element("list"); containerElement.addContent(listElement); listElement.addContent(new Element("unknown")); listElement.addContent(new Element("item")); listElement.addContent(new Element("unknown")); myContainer.registerProperty(PROPERTY, "item", EXTERNALIZER); myContainer.readExternal(containerElement); List<MockJDOMExternalizable> list = PROPERTY.get(myContainer); assertEquals(1, list.size()); }
20. FilterInfo#writeExternal()
Project: intellij-community
File: FilterInfo.java
File: FilterInfo.java
@Override public void writeExternal(Element filterElement) { Element option = new Element(ELEMENT_OPTION); filterElement.addContent(option); option.setAttribute(ATTRIBUTE_NAME, FILTER_NAME); if (myName != null) { option.setAttribute(ATTRIBUTE_VALUE, myName); } option = new Element(ELEMENT_OPTION); filterElement.addContent(option); option.setAttribute(ATTRIBUTE_NAME, FILTER_DESCRIPTION); if (myDescription != null) { option.setAttribute(ATTRIBUTE_VALUE, myDescription); } option = new Element(ELEMENT_OPTION); filterElement.addContent(option); option.setAttribute(ATTRIBUTE_NAME, FILTER_REGEXP); if (myRegExp != null) { option.setAttribute(ATTRIBUTE_VALUE, myRegExp); } }
21. EntryPointsConverterTest#doTest()
Project: intellij-community
File: EntryPointsConverterTest.java
File: EntryPointsConverterTest.java
private static void doTest(String type, String fqName, String expectedFQName) throws Exception { final Element entryPoints = setUpEntryPoint(type, fqName); final HashMap<String, SmartRefElementPointer> persistentEntryPoints = new HashMap<String, SmartRefElementPointer>(); EntryPointsManagerBase.convert(entryPoints, persistentEntryPoints); final Element testElement = new Element("comp"); EntryPointsManagerBase.writeExternal(testElement, persistentEntryPoints, new JDOMExternalizableStringList()); final Element expectedEntryPoints = setUpEntryPoint(type, expectedFQName); expectedEntryPoints.setAttribute("version", "2.0"); final Element expected = new Element("comp"); expected.addContent(expectedEntryPoints); assertTrue(JDOMUtil.areElementsEqual(testElement, expected)); }
22. XMLUtilities#renameCollection()
Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
File: XMLUtilities.java
/** * * @param newName * the new name for this fully wrapped BioMOBY collection * @param element * the fully wrapped BioMOBY collection * @return @return an element 'Collection' representing the renamed collection * @throws MobyException * if the message is invalid */ public static Element renameCollection(String newName, Element element) throws MobyException { Element e = (Element) element.clone(); Element mobyData = extractMobyData(e); Element coll = mobyData.getChild("Collection"); if (coll == null) coll = mobyData.getChild("Collection", MOBY_NS); if (coll == null) return e; coll.removeAttribute("articleName"); coll.removeAttribute("articleName", MOBY_NS); coll.setAttribute("articleName", newName, MOBY_NS); return coll; }
23. XMLUtilities#createServiceInput()
Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
File: XMLUtilities.java
/** * * @param elements * the fully wrapped moby simples and/or collections to wrap an * input message around * @param queryID * the queryID for this input * @return a fully wrapped message with an appropriate queryID and elements * added to it * @throws MobyException * if an element is invalid. */ public static Element createServiceInput(Element[] elements, String queryID) throws MobyException { // create the main elements Element MOBY = new Element("MOBY", MOBY_NS); Element mobyContent = new Element("mobyContent", MOBY_NS); Element mobyData = new Element("mobyData", MOBY_NS); mobyData.setAttribute("queryID", (queryID == null ? "" : queryID), MOBY_NS); // add the content MOBY.addContent(mobyContent); mobyContent.addContent(mobyData); // iterate through elements adding the content of mobyData for (int i = 0; i < elements.length; i++) { Element e = (Element) elements[i].clone(); e = extractMobyData(e); mobyData.addContent(e.cloneContent()); } return MOBY; }
24. GoControlLog#writeLogFile()
Project: gocd
File: GoControlLog.java
File: GoControlLog.java
/** * Writes the current build log to the appropriate directory and filename. */ public void writeLogFile(Date now) throws IOException { String logFilename = decideLogfileName(now); // Add the logDir as an info element Element logDirElement = new Element("property"); logDirElement.setAttribute("name", "logdir"); logDirElement.setAttribute("value", new File(logDir).getAbsolutePath()); buildLog.getChild("info").addContent(logDirElement); // Add the logFile as an info element Element logFileElement = new Element("property"); logFileElement.setAttribute("name", "logfile"); logFileElement.setAttribute("value", logFilename); buildLog.getChild("info").addContent(logFileElement); File logfile = new File(logDir, logFilename); if (LOG.isDebugEnabled()) { LOG.debug("Writing log file [" + logfile.getAbsolutePath() + "]"); } writeLogFile(logfile, buildLog); }
25. RestUtils#constructSerializerInfoXml()
Project: voldemort
File: RestUtils.java
File: RestUtils.java
/** * Given a storedefinition, constructs the xml string to be sent out in * response to a "schemata" fetch request * * @param storeDefinition * @return serialized store definition */ public static String constructSerializerInfoXml(StoreDefinition storeDefinition) { Element store = new Element(StoreDefinitionsMapper.STORE_ELMT); store.addContent(new Element(StoreDefinitionsMapper.STORE_NAME_ELMT).setText(storeDefinition.getName())); Element keySerializer = new Element(StoreDefinitionsMapper.STORE_KEY_SERIALIZER_ELMT); StoreDefinitionsMapper.addSerializer(keySerializer, storeDefinition.getKeySerializer()); store.addContent(keySerializer); Element valueSerializer = new Element(StoreDefinitionsMapper.STORE_VALUE_SERIALIZER_ELMT); StoreDefinitionsMapper.addSerializer(valueSerializer, storeDefinition.getValueSerializer()); store.addContent(valueSerializer); XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat()); return serializer.outputString(store); }
26. SubmitPigXCommand#getWorkflowXml()
Project: oozie
File: SubmitPigXCommand.java
File: SubmitPigXCommand.java
/* * (non-Javadoc) * * @see * org.apache.oozie.command.wf.SubmitHttpCommand#getWorkflowXml(org.apache * .hadoop.conf.Configuration) */ @Override protected String getWorkflowXml(Configuration conf) { for (String key : MANDATORY_OOZIE_CONFS) { String value = conf.get(key); if (value == null) { throw new RuntimeException(key + " is not specified"); } } Namespace ns = Namespace.getNamespace("uri:oozie:workflow:0.2"); Element root = new Element("workflow-app", ns); root.setAttribute("name", "oozie-pig"); Element start = new Element("start", ns); start.setAttribute("to", "pig1"); root.addContent(start); Element action = new Element("action", ns); action.setAttribute("name", "pig1"); Element pig = generatePigSection(conf, ns); action.addContent(pig); Element ok = new Element("ok", ns); ok.setAttribute("to", "end"); action.addContent(ok); Element error = new Element("error", ns); error.setAttribute("to", "fail"); action.addContent(error); root.addContent(action); Element kill = new Element("kill", ns); kill.setAttribute("name", "fail"); Element message = new Element("message", ns); message.addContent("Pig failed, error message[${wf:errorMessage(wf:lastErrorNode())}]"); kill.addContent(message); root.addContent(kill); Element end = new Element("end", ns); end.setAttribute("name", "end"); root.addContent(end); return XmlUtils.prettyPrint(root).toString(); }
27. SubmitPigCommand#getWorkflowXml()
Project: oozie
File: SubmitPigCommand.java
File: SubmitPigCommand.java
/* * (non-Javadoc) * * @see * org.apache.oozie.command.wf.SubmitHttpCommand#getWorkflowXml(org.apache * .hadoop.conf.Configuration) */ @Override protected String getWorkflowXml(Configuration conf) { for (String key : MANDATORY_OOZIE_CONFS) { String value = conf.get(key); if (value == null) { throw new RuntimeException(key + " is not specified"); } } Namespace ns = Namespace.getNamespace("uri:oozie:workflow:0.2"); Element root = new Element("workflow-app", ns); root.setAttribute("name", "oozie-pig"); Element start = new Element("start", ns); start.setAttribute("to", "pig1"); root.addContent(start); Element action = new Element("action", ns); action.setAttribute("name", "pig1"); Element pig = generatePigSection(conf, ns); action.addContent(pig); Element ok = new Element("ok", ns); ok.setAttribute("to", "end"); action.addContent(ok); Element error = new Element("error", ns); error.setAttribute("to", "fail"); action.addContent(error); root.addContent(action); Element kill = new Element("kill", ns); kill.setAttribute("name", "fail"); Element message = new Element("message", ns); message.addContent("Pig failed, error message[${wf:errorMessage(wf:lastErrorNode())}]"); kill.addContent(message); root.addContent(kill); Element end = new Element("end", ns); end.setAttribute("name", "end"); root.addContent(end); return XmlUtils.prettyPrint(root).toString(); }
28. SubmitMRXCommand#getWorkflowXml()
Project: oozie
File: SubmitMRXCommand.java
File: SubmitMRXCommand.java
/* * (non-Javadoc) * * @see * org.apache.oozie.command.wf.SubmitHttpCommand#getWorkflowXml(org.apache * .hadoop.conf.Configuration) */ @Override protected String getWorkflowXml(Configuration conf) { for (String key : MANDATORY_OOZIE_CONFS) { String value = conf.get(key); if (value == null) { throw new RuntimeException(key + " is not specified"); } } Namespace ns = Namespace.getNamespace("uri:oozie:workflow:0.2"); Element root = new Element("workflow-app", ns); root.setAttribute("name", "oozie-mapreduce"); Element start = new Element("start", ns); start.setAttribute("to", "hadoop1"); root.addContent(start); Element action = new Element("action", ns); action.setAttribute("name", "hadoop1"); Element mapreduce = generateMRSection(conf, ns); action.addContent(mapreduce); Element ok = new Element("ok", ns); ok.setAttribute("to", "end"); action.addContent(ok); Element error = new Element("error", ns); error.setAttribute("to", "fail"); action.addContent(error); root.addContent(action); Element kill = new Element("kill", ns); kill.setAttribute("name", "fail"); Element message = new Element("message", ns); message.addContent("Map/Reduce failed, error message[${wf:errorMessage(wf:lastErrorNode())}]"); kill.addContent(message); root.addContent(kill); Element end = new Element("end", ns); end.setAttribute("name", "end"); root.addContent(end); return XmlUtils.prettyPrint(root).toString(); }
29. SubmitMRCommand#getWorkflowXml()
Project: oozie
File: SubmitMRCommand.java
File: SubmitMRCommand.java
/* * (non-Javadoc) * * @see * org.apache.oozie.command.wf.SubmitHttpCommand#getWorkflowXml(org.apache * .hadoop.conf.Configuration) */ @Override protected String getWorkflowXml(Configuration conf) { for (String key : MANDATORY_OOZIE_CONFS) { String value = conf.get(key); if (value == null) { throw new RuntimeException(key + " is not specified"); } } Namespace ns = Namespace.getNamespace("uri:oozie:workflow:0.2"); Element root = new Element("workflow-app", ns); root.setAttribute("name", "oozie-mapreduce"); Element start = new Element("start", ns); start.setAttribute("to", "hadoop1"); root.addContent(start); Element action = new Element("action", ns); action.setAttribute("name", "hadoop1"); Element mapreduce = generateMRSection(conf, ns); action.addContent(mapreduce); Element ok = new Element("ok", ns); ok.setAttribute("to", "end"); action.addContent(ok); Element error = new Element("error", ns); error.setAttribute("to", "fail"); action.addContent(error); root.addContent(action); Element kill = new Element("kill", ns); kill.setAttribute("name", "fail"); Element message = new Element("message", ns); message.addContent("Map/Reduce failed, error message[${wf:errorMessage(wf:lastErrorNode())}]"); kill.addContent(message); root.addContent(kill); Element end = new Element("end", ns); end.setAttribute("name", "end"); root.addContent(end); return XmlUtils.prettyPrint(root).toString(); }
30. VimPlugin#getState()
Project: ideavim
File: VimPlugin.java
File: VimPlugin.java
@Override public Element getState() { LOG.debug("Saving state"); final Element element = new Element("ideavim"); // Save whether the plugin is enabled or not final Element state = new Element("state"); state.setAttribute("version", Integer.toString(STATE_VERSION)); state.setAttribute("enabled", Boolean.toString(enabled)); element.addContent(state); mark.saveData(element); register.saveData(element); search.saveData(element); history.saveData(element); key.saveData(element); editor.saveData(element); return element; }
31. PathMacrosCollectorTest#testWithFilter()
Project: intellij-community
File: PathMacrosCollectorTest.java
File: PathMacrosCollectorTest.java
public void testWithFilter() throws Exception { Element root = new Element("root"); final Element testTag = new Element("test"); testTag.setAttribute("path", "$MACRO$"); testTag.setAttribute("ignore", "$PATH$"); root.addContent(testTag); final Set<String> macros = PathMacrosCollector.getMacroNames(root, null, new PathMacrosImpl()); assertEquals(2, macros.size()); assertTrue(macros.contains("MACRO")); assertTrue(macros.contains("PATH")); final Set<String> filtered = PathMacrosCollector.getMacroNames(root, new PathMacroFilter() { @Override public boolean skipPathMacros(Attribute attribute) { return "ignore".equals(attribute.getName()); } }, new PathMacrosImpl()); assertEquals(1, filtered.size()); assertTrue(macros.contains("MACRO")); }
32. PathMacrosCollectorTest#testWithRecursiveFilter()
Project: intellij-community
File: PathMacrosCollectorTest.java
File: PathMacrosCollectorTest.java
public void testWithRecursiveFilter() throws Exception { Element root = new Element("root"); final Element configuration = new Element("configuration"); configuration.setAttribute("value", "some text$macro5$fdsjfhdskjfsd$MACRO$"); configuration.setAttribute("value2", "file://$root$/some/path/just$file$name.txt"); root.addContent(configuration); final Set<String> macros = PathMacrosCollector.getMacroNames(root, new PathMacroFilter() { @Override public boolean recursePathMacros(Attribute attribute) { return "value".equals(attribute.getName()); } }, new PathMacrosImpl()); UsefulTestCase.assertSameElements(macros, "macro5", "MACRO", "root"); }
33. WindowManagerImpl#getState()
Project: intellij-community
File: WindowManagerImpl.java
File: WindowManagerImpl.java
@Nullable @Override public Element getState() { Element frameState = getFrameState(); if (frameState == null) { return null; } Element state = new Element("state"); state.addContent(frameState); // Save default layout Element layoutElement = new Element(DesktopLayout.TAG); state.addContent(layoutElement); myLayout.writeExternal(layoutElement); return state; }
34. UsageStatisticsPersistenceComponent#getState()
Project: intellij-community
File: UsageStatisticsPersistenceComponent.java
File: UsageStatisticsPersistenceComponent.java
@Override public Element getState() { Element element = new Element("state"); for (Map.Entry<GroupDescriptor, Set<UsageDescriptor>> entry : ConvertUsagesUtil.sortDescriptorsByPriority(getSentUsages()).entrySet()) { Element projectElement = new Element(GROUP_TAG); projectElement.setAttribute(GROUP_ID_ATTR, entry.getKey().getId()); projectElement.setAttribute(GROUP_PRIORITY_ATTR, Double.toString(entry.getKey().getPriority())); projectElement.setAttribute(DATA_ATTR, ConvertUsagesUtil.convertValueMap(entry.getValue())); element.addContent(projectElement); } element.setAttribute(LAST_TIME_ATTR, String.valueOf(getLastTimeSent())); element.setAttribute(IS_ALLOWED_ATTR, String.valueOf(isAllowed())); element.setAttribute(SHOW_NOTIFICATION_ATTR, String.valueOf(isShowNotification())); element.setAttribute(PERIOD_ATTR, myPeriod.getName()); return element; }
35. PathMacrosCollectorTest#testWithFilter()
Project: consulo
File: PathMacrosCollectorTest.java
File: PathMacrosCollectorTest.java
public void testWithFilter() throws Exception { Element root = new Element("root"); final Element testTag = new Element("test"); testTag.setAttribute("path", "$MACRO$"); testTag.setAttribute("ignore", "$PATH$"); root.addContent(testTag); final Set<String> macros = PathMacrosCollectorImpl.getMacroNames(root, null, new PathMacrosImpl()); assertEquals(2, macros.size()); assertTrue(macros.contains("MACRO")); assertTrue(macros.contains("PATH")); final Set<String> filtered = PathMacrosCollectorImpl.getMacroNames(root, new PathMacroFilter() { @Override public boolean skipPathMacros(Attribute attribute) { return "ignore".equals(attribute.getName()); } }, new PathMacrosImpl()); assertEquals(1, filtered.size()); assertTrue(macros.contains("MACRO")); }
36. WindowManagerImpl#getState()
Project: consulo
File: WindowManagerImpl.java
File: WindowManagerImpl.java
@Nullable @Override public Element getState() { Element frameState = getFrameState(); if (frameState == null) { return null; } Element state = new Element("state"); state.addContent(frameState); // Save default layout Element layoutElement = new Element(DesktopLayout.TAG); state.addContent(layoutElement); myLayout.writeExternal(layoutElement); return state; }
37. XMLUtilities#createMultipleInvokations()
Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
File: XMLUtilities.java
/** * * @param elements * @return * @throws MobyException */ public static Element createMultipleInvokations(Element[] elements) throws MobyException { Element MOBY = new Element("MOBY", MOBY_NS); Element mobyContent = new Element("mobyContent", MOBY_NS); Element serviceNotes = null; for (int i = 0; i < elements.length; i++) { if (serviceNotes == null) { serviceNotes = getServiceNotes((Element) elements[i].clone()); if (serviceNotes != null) mobyContent.addContent(serviceNotes.detach()); } Element mobyData = new Element("mobyData", MOBY_NS); Element md = extractMobyData((Element) elements[i].clone()); String queryID = getQueryID((Element) elements[i].clone()); mobyData.setAttribute("queryID", queryID, MOBY_NS); mobyData.addContent(md.cloneContent()); mobyContent.addContent(mobyData); } MOBY.addContent(mobyContent); return MOBY; }
38. XMLUtilities#getWrappedSimplesFromCollection()
Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
File: XMLUtilities.java
/** * * @param name * the name of the collection to extract the simples from. * @param element * the Element to extract from * @return an array of Elements objects that represent the simples, with the * name of the collection * @throws MobyException * MobyException if the collection doesnt exist or the xml is * invalid */ public static Element[] getWrappedSimplesFromCollection(String name, Element element) throws MobyException { Element el = (Element) element.clone(); String queryID = getQueryID(el); Element collection = getCollection(name, el); Element serviceNotes = getServiceNotes(el); List list = collection.getChildren("Simple"); if (list.isEmpty()) list = collection.getChildren("Simple", MOBY_NS); if (list.isEmpty()) return new Element[] {}; Vector vector = new Vector(); for (Iterator it = list.iterator(); it.hasNext(); ) { Element e = (Element) it.next(); e.setAttribute("articleName", name, MOBY_NS); e = createMobyDataElementWrapper(e, queryID + "_split" + queryCount++, serviceNotes); vector.add(e); } Element[] elements = new Element[vector.size()]; vector.copyInto(elements); return elements; }
39. XMLUtilities#getSimplesFromCollection()
Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
File: XMLUtilities.java
/** * * @param name * the name of the collection to extract the simples from. * @param element * the Element to extract from * @return an array of Elements objects that represent the 'unwrapped' * simples * @throws MobyException */ public static Element[] getSimplesFromCollection(Element element) throws MobyException { Element e = (Element) element.clone(); Element mobyData = extractMobyData(e); Element collection = mobyData.getChild("Collection"); if (collection == null) collection = mobyData.getChild("Collection", MOBY_NS); List list = collection.getChildren("Simple"); if (list.isEmpty()) list = collection.getChildren("Simple", MOBY_NS); if (list.isEmpty()) return new Element[] {}; Vector vector = new Vector(); for (Iterator it = list.iterator(); it.hasNext(); ) { vector.add(it.next()); } Element[] elements = new Element[vector.size()]; vector.copyInto(elements); return elements; }
40. PathMacrosCollectorTest#testWithRecursiveFilter()
Project: consulo
File: PathMacrosCollectorTest.java
File: PathMacrosCollectorTest.java
public void testWithRecursiveFilter() throws Exception { Element root = new Element("root"); final Element configuration = new Element("configuration"); configuration.setAttribute("value", "some text$macro5$fdsjfhdskjfsd$MACRO$"); root.addContent(configuration); final Set<String> macros = PathMacrosCollectorImpl.getMacroNames(root, new PathMacroFilter() { @Override public boolean recursePathMacros(Attribute attribute) { return "value".equals(attribute.getName()); } }, new PathMacrosImpl()); assertEquals(2, macros.size()); assertTrue(macros.contains("macro5")); assertTrue(macros.contains("MACRO")); }
41. UsageStatisticsPersistenceComponent#getState()
Project: consulo
File: UsageStatisticsPersistenceComponent.java
File: UsageStatisticsPersistenceComponent.java
@Override public Element getState() { Element element = new Element("state"); for (Map.Entry<GroupDescriptor, Set<UsageDescriptor>> entry : ConvertUsagesUtil.sortDescriptorsByPriority(getSentUsages()).entrySet()) { Element projectElement = new Element(GROUP_TAG); projectElement.setAttribute(GROUP_ID_ATTR, entry.getKey().getId()); projectElement.setAttribute(GROUP_PRIORITY_ATTR, Double.toString(entry.getKey().getPriority())); projectElement.setAttribute(DATA_ATTR, ConvertUsagesUtil.convertValueMap(entry.getValue())); element.addContent(projectElement); } element.setAttribute(LAST_TIME_ATTR, String.valueOf(getLastTimeSent())); element.setAttribute(IS_ALLOWED_ATTR, String.valueOf(isAllowed())); element.setAttribute(PERIOD_ATTR, myPeriod.getName()); return element; }
42. MartServiceXMLHandler#martQueryToElement()
Project: incubator-taverna-plugin-bioinformatics
File: MartServiceXMLHandler.java
File: MartServiceXMLHandler.java
/** * Converts a <code>MartQuery</code> to an XML element. * * @param martQuery * the <code>MartQuery</code> to serialize * @param namespace * the <code>Namespace</code> to use when constructing the * <code>Element</code> * @return an XML serialization of the <code>MartQuery</code> */ public static Element martQueryToElement(MartQuery martQuery, Namespace namespace) { Element element = new Element(MART_QUERY_ELEMENT, namespace); element.addContent(martServiceToElement(martQuery.getMartService(), namespace)); element.addContent(datasetToElement(martQuery.getMartDataset(), namespace)); element.addContent(QueryXMLHandler.queryToElement(martQuery.getQuery(), namespace)); Set linkedDatasets = martQuery.getLinkedDatasets(); if (linkedDatasets.size() > 0) { Element linksElement = new Element(LINKED_DATASETS_ELEMENT, namespace); for (Iterator iter = linkedDatasets.iterator(); iter.hasNext(); ) { String datasetName = (String) iter.next(); Element datasetElement = new Element(LINKED_DATASETS_ELEMENT, namespace); datasetElement.setAttribute(NAME_ATTRIBUTE, datasetName); datasetElement.setAttribute(LINK_ATTRIBUTE, martQuery.getLink(datasetName)); linksElement.addContent(datasetElement); } element.addContent(linksElement); } return element; }
43. LocalMechanismCreator#convert()
Project: incubator-taverna-common-activities
File: LocalMechanismCreator.java
File: LocalMechanismCreator.java
public InvocationMechanism convert(Element detailsElement, String mechanismName) { ExternalToolLocalInvocationMechanism result = new ExternalToolLocalInvocationMechanism(); result.setName(mechanismName); Element directoryElement = detailsElement.getChild("directory"); if (directoryElement != null) { result.setDirectory(directoryElement.getText()); } Element shellPrefixElement = detailsElement.getChild("shellPrefix"); if (shellPrefixElement != null) { result.setShellPrefix(shellPrefixElement.getText()); } Element linkCommandElement = detailsElement.getChild("linkCommand"); if (linkCommandElement != null) { result.setLinkCommand(linkCommandElement.getText()); } Element retrieveDataElement = detailsElement.getChild("retrieveData"); result.setRetrieveData(retrieveDataElement != null); return result; }
44. XmlSerializerTest#testShuffledDeserialize()
Project: consulo
File: XmlSerializerTest.java
File: XmlSerializerTest.java
public void testShuffledDeserialize() { BeanWithPublicFields bean = new BeanWithPublicFields(); bean.INT_V = 987; bean.STRING_V = "1234"; Element element = serialize(bean, null); Element node = (Element) element.getChildren().get(0); element.removeContent(node); element.addContent(node); bean = XmlSerializer.deserialize(element, bean.getClass()); assert bean != null; assertEquals(987, bean.INT_V); assertEquals("1234", bean.STRING_V); }
45. OvalFileAggregator#buildDocument()
Project: spacewalk
File: OvalFileAggregator.java
File: OvalFileAggregator.java
private void buildDocument() { Element defsElement = new Element("definitions"); attachChildren(defsElement, defs); Element testsElement = new Element("tests"); attachChildren(testsElement, tests); Element objectsElement = new Element("objects"); attachChildren(objectsElement, objects); Element statesElement = new Element("states"); attachChildren(statesElement, states); List children = aggregate.getRootElement().getChildren(); children.add(defsElement); children.add(testsElement); children.add(objectsElement); children.add(statesElement); }
46. OPMLExporter#createElement()
Project: RSSOwl
File: OPMLExporter.java
File: OPMLExporter.java
private Element createElement(IFolder folder, boolean exportPreferences) { Element folderElement = new Element(Tag.OUTLINE.get()); folderElement.setAttribute(Attributes.TEXT.get(), folder.getName()); folderElement.setAttribute(Attributes.IS_SET.get(), String.valueOf(folder.getParent() == null), RSSOWL_NS); folderElement.setAttribute(Attributes.ID.get(), String.valueOf(folder.getId()), RSSOWL_NS); /* Export Preferences if set */ if (exportPreferences) exportPreferences(folderElement, folder); return folderElement; }
47. ChangeListManagerSerialization#readExternal()
Project: intellij-community
File: ChangeListManagerSerialization.java
File: ChangeListManagerSerialization.java
@SuppressWarnings({ "unchecked" }) public void readExternal(final Element element) throws InvalidDataException { final List<Element> listNodes = element.getChildren(NODE_LIST); for (Element listNode : listNodes) { readChangeList(listNode); } final List<Element> ignoredNodes = element.getChildren(NODE_IGNORED); for (Element ignoredNode : ignoredNodes) { readFileToIgnore(ignoredNode); } Element manuallyRemovedFromIgnoredTag = element.getChild(MANUALLY_REMOVED_FROM_IGNORED); Set<String> manuallyRemovedFromIgnoredPaths = new HashSet<String>(); if (manuallyRemovedFromIgnoredTag != null) { for (Element tag : manuallyRemovedFromIgnoredTag.getChildren(DIRECTORY_TAG)) { manuallyRemovedFromIgnoredPaths.add(tag.getAttributeValue(ATT_PATH)); } } myIgnoredIdeaLevel.setDirectoriesManuallyRemovedFromIgnored(manuallyRemovedFromIgnoredPaths); }
48. JDOMExternalizer#readMap()
Project: intellij-community
File: JDOMExternalizer.java
File: JDOMExternalizer.java
public static void readMap(Element root, Map<String, String> map, @NonNls @Nullable String rootName, @NonNls String entryName) { Element mapRoot; if (StringUtil.isNotEmpty(rootName)) { mapRoot = root.getChild(rootName); } else { mapRoot = root; } if (mapRoot == null) { return; } for (@NonNls Element element : mapRoot.getChildren(entryName)) { String name = element.getAttributeValue("name"); if (name != null) { map.put(name, element.getAttributeValue("value")); } } }
49. LibraryOrderEntryImpl#writeExternal()
Project: intellij-community
File: LibraryOrderEntryImpl.java
File: LibraryOrderEntryImpl.java
@Override public void writeExternal(@NotNull Element rootElement) throws WriteExternalException { final Element element = OrderEntryFactory.createOrderEntryElement(ENTRY_TYPE); final String libraryLevel = getLibraryLevel(); if (myExported) { element.setAttribute(EXPORTED_ATTR, ""); } myScope.writeExternal(element); element.setAttribute(NAME_ATTR, getLibraryName()); element.setAttribute(LEVEL_ATTR, libraryLevel); rootElement.addContent(element); }
50. ExternalizablePropertyTest#testWriteList()
Project: intellij-community
File: ExternalizablePropertyTest.java
File: ExternalizablePropertyTest.java
public void testWriteList() throws WriteExternalException { myContainer.registerProperty(PROPERTY, "item", EXTERNALIZER); PROPERTY.getModifiableList(myContainer).add(new MockJDOMExternalizable()); Element containerElement = new Element("xxx"); myContainer.writeExternal(containerElement); List children = containerElement.getChildren(); assertEquals(1, children.size()); Element listElement = (Element) children.get(0); assertEquals("list", listElement.getName()); children = listElement.getChildren(); assertEquals(1, children.size()); Element itemElement = (Element) children.get(0); assertEquals("item", itemElement.getName()); }
51. FileColorConfiguration#save()
Project: intellij-community
File: FileColorConfiguration.java
File: FileColorConfiguration.java
public void save(@NotNull final Element e) { if (!isValid(null)) { return; } final Element tab = new Element(FileColorsModel.FILE_COLOR); tab.setAttribute(SCOPE_NAME, getScopeName()); tab.setAttribute(COLOR, myColorName); e.addContent(tab); }
52. EnvironmentVariablesData#readExternal()
Project: intellij-community
File: EnvironmentVariablesData.java
File: EnvironmentVariablesData.java
@NotNull public static EnvironmentVariablesData readExternal(@NotNull Element element) { Element envsElement = element.getChild(ENVS); if (envsElement == null) { return DEFAULT; } Map<String, String> envs = ImmutableMap.of(); String passParentEnvsStr = envsElement.getAttributeValue(PASS_PARENT_ENVS); boolean passParentEnvs = passParentEnvsStr == null || Boolean.parseBoolean(passParentEnvsStr); for (Element envElement : envsElement.getChildren(ENV)) { String envName = envElement.getAttributeValue(NAME); String envValue = envElement.getAttributeValue(VALUE); if (envName != null && envValue != null) { if (envs.isEmpty()) { envs = ContainerUtil.newLinkedHashMap(); } envs.put(envName, envValue); } } return create(envs, passParentEnvs); }
53. ConversionContextImpl#findModuleFiles()
Project: intellij-community
File: ConversionContextImpl.java
File: ConversionContextImpl.java
private File[] findModuleFiles(final Element root) { final Element modulesManager = JDomSerializationUtil.findComponent(root, ModuleManagerImpl.COMPONENT_NAME); if (modulesManager == null) return new File[0]; final Element modules = modulesManager.getChild(ModuleManagerImpl.ELEMENT_MODULES); if (modules == null) return new File[0]; final ExpandMacroToPathMap macros = createExpandMacroMap(); List<File> files = new ArrayList<File>(); for (Element module : JDOMUtil.getChildren(modules, ModuleManagerImpl.ELEMENT_MODULE)) { String filePath = module.getAttributeValue(ModuleManagerImpl.ATTRIBUTE_FILEPATH); filePath = macros.substitute(filePath, true); files.add(new File(FileUtil.toSystemDependentName(filePath))); } return files.toArray(new File[files.size()]); }
54. ArrangementSettingsSerializationTest#testSectionSerialize()
Project: intellij-community
File: ArrangementSettingsSerializationTest.java
File: ArrangementSettingsSerializationTest.java
@Test public void testSectionSerialize() { final ArrayList<ArrangementSectionRule> sections = ContainerUtil.newArrayList(section("start section", "end section", rule(true, METHOD, PRIVATE), rule(false, METHOD, PUBLIC)), section("start section", "end section", rule(true, FIELD))); final StdArrangementSettings settings = settings(ContainerUtil.newArrayList(group(OVERRIDDEN_METHODS)), sections); final Element holder = doSerializationTest(settings, emptySettings()); assertTrue(holder.getChildren().size() == 2); assertNotNull(holder.getChild("groups")); final Element rules = holder.getChild("rules"); assertNotNull(rules); assertTrue(rules.getChildren().size() == 2); final Element section = rules.getChild("section"); assertEquals(section.getAttribute("start_comment").getValue(), "start section"); assertEquals(section.getAttribute("end_comment").getValue(), "end section"); }
55. ArrangementSettingsSerializationTest#testSimpleSectionSerialize()
Project: intellij-community
File: ArrangementSettingsSerializationTest.java
File: ArrangementSettingsSerializationTest.java
@Test public void testSimpleSectionSerialize() { final StdArrangementSettings settings = settings(ContainerUtil.newArrayList(group(OVERRIDDEN_METHODS)), ContainerUtil.newArrayList(section(true, FIELD))); final Element holder = doSerializationTest(settings, emptySettings()); assertTrue(holder.getChildren().size() == 2); assertNotNull(holder.getChild("groups")); final Element rules = holder.getChild("rules"); assertNotNull(rules); assertTrue(rules.getChildren().size() == 1); final Element section = rules.getChild("section"); assertNotNull(section); assertTrue(section.getChildren().size() == 1); assertNotNull(section.getChild("rule")); }
56. ExternalizablePropertyTest#testWriteList()
Project: consulo
File: ExternalizablePropertyTest.java
File: ExternalizablePropertyTest.java
public void testWriteList() throws WriteExternalException { myContainer.registerProperty(PROPERTY, "item", EXTERNALIZER); PROPERTY.getModifiableList(myContainer).add(new MockJDOMExternalizable()); Element containerElement = new Element("xxx"); myContainer.writeExternal(containerElement); List children = containerElement.getChildren(); assertEquals(1, children.size()); Element listElement = (Element) children.get(0); assertEquals("list", listElement.getName()); children = listElement.getChildren(); assertEquals(1, children.size()); Element itemElement = (Element) children.get(0); assertEquals("item", itemElement.getName()); }
57. FileColorConfiguration#save()
Project: consulo
File: FileColorConfiguration.java
File: FileColorConfiguration.java
public void save(@NotNull final Element e) { if (!isValid(null)) { return; } final Element tab = new Element(FileColorsModel.FILE_COLOR); tab.setAttribute(SCOPE_NAME, getScopeName()); tab.setAttribute(COLOR, myColorName); e.addContent(tab); }
58. DefaultArrangementSettingsSerializer#serialize()
Project: consulo
File: DefaultArrangementSettingsSerializer.java
File: DefaultArrangementSettingsSerializer.java
@Nullable public Element serialize(@NotNull ArrangementMatchRule rule) { Element matcherElement = myMatcherSerializer.serialize(rule.getMatcher()); if (matcherElement == null) { return null; } Element result = new Element(RULE_ELEMENT_NAME); result.addContent(new Element(MATCHER_ELEMENT_NAME).addContent(matcherElement)); if (rule.getOrderType() != ArrangementMatchRule.DEFAULT_ORDER_TYPE) { result.addContent(new Element(ORDER_TYPE_ELEMENT_NAME).setText(rule.getOrderType().getId())); } return result; }
59. ModuleCompilerPathsManagerImpl#getState()
Project: consulo
File: ModuleCompilerPathsManagerImpl.java
File: ModuleCompilerPathsManagerImpl.java
@Nullable @Override public Element getState() { if (myInheritOutput) { return null; } Element moduleElement = new Element(MODULE_OUTPUT_TAG); moduleElement.setAttribute(NAME, myModule.getName()); moduleElement.setAttribute(EXCLUDE, String.valueOf(isExcludeOutput())); for (Map.Entry<String, VirtualFilePointer> tempEntry : myVirtualFilePointers.entrySet()) { final Element elementForOutput = createElementForOutput(tempEntry.getValue()); elementForOutput.setAttribute(TYPE, tempEntry.getKey()); moduleElement.addContent(elementForOutput); } return moduleElement; }
60. SmartRefElementPointerImpl#writeExternal()
Project: consulo
File: SmartRefElementPointerImpl.java
File: SmartRefElementPointerImpl.java
@Override public void writeExternal(Element parentNode) { Element element = new Element(ENTRY_POINT); element.setAttribute(TYPE_ATTR, myType); element.setAttribute(FQNAME_ATTR, getFQName()); /*if (myRefElement != null) { final RefEntity entity = myRefElement.getOwner(); if (entity != null) { new SmartRefElementPointerImpl(entity, myIsPersistent).writeExternal(element); } }*/ parentNode.addContent(element); }
61. XMLSplitterSerialisationHelper#typeDescriptorToExtensionXML()
Project: incubator-taverna-common-activities
File: XMLSplitterSerialisationHelper.java
File: XMLSplitterSerialisationHelper.java
/** * Generates the extensions XML that describes the TypeDescriptor to allow * an XMLInputSplitter or XMLOutputSplitter to be reconstructed using * consumeXML. */ public static Element typeDescriptorToExtensionXML(TypeDescriptor descriptor) { Element result = new Element("extensions", XScuflNS); Element type = null; if (descriptor instanceof ComplexTypeDescriptor) { type = constructElementForComplexType((ComplexTypeDescriptor) descriptor, new ArrayList<String>()); } else if (descriptor instanceof ArrayTypeDescriptor) { type = constructElementForArrayType((ArrayTypeDescriptor) descriptor, new ArrayList<String>()); } result.addContent(type); return result; }
62. SearchGroup#readData()
Project: ideavim
File: SearchGroup.java
File: SearchGroup.java
public void readData(@NotNull Element element) { logger.debug("readData"); Element search = element.getChild("search"); if (search == null) { return; } lastSearch = getSafeChildText(search, "last-search"); lastOffset = getSafeChildText(search, "last-offset"); lastPattern = getSafeChildText(search, "last-pattern"); lastReplace = getSafeChildText(search, "last-replace"); lastSubstitute = getSafeChildText(search, "last-substitute"); Element dir = search.getChild("last-dir"); lastDir = Integer.parseInt(dir.getText()); Element show = search.getChild("show-last"); final ListOption vimInfo = Options.getInstance().getListOption(Options.VIMINFO); final boolean disableHighlight = vimInfo != null && vimInfo.contains("h"); showSearchHighlight = !disableHighlight && Boolean.valueOf(show.getText()); if (logger.isDebugEnabled()) { logger.debug("show=" + show + "(" + show.getText() + ")"); logger.debug("showSearchHighlight=" + showSearchHighlight); } }
63. DirectoryEntriesTest#shouldListAllArtifactsWhenArtifactsNotPurged()
Project: gocd
File: DirectoryEntriesTest.java
File: DirectoryEntriesTest.java
@Test public void shouldListAllArtifactsWhenArtifactsNotPurged() throws Exception { HtmlRenderer renderer = new HtmlRenderer("context"); DirectoryEntries directoryEntries = new DirectoryEntries(); directoryEntries.add(new FolderDirectoryEntry("cruise-output", "", new DirectoryEntries())); directoryEntries.add(new FolderDirectoryEntry("some-artifact", "", new DirectoryEntries())); directoryEntries.render(renderer); Element document = getRenderedDocument(renderer); assertThat(document.getChildren().size(), is(2)); Element cruiseOutputElement = (Element) document.getChildren().get(0); assertThat(cruiseOutputElement.getChild("div").getChild("span").getChild("a").getTextNormalize(), is("cruise-output")); Element artifactElement = (Element) document.getChildren().get(1); assertThat(artifactElement.getChild("div").getChild("span").getChild("a").getTextNormalize(), is("some-artifact")); }
64. ChangeListManagerSerialization#readExternal()
Project: consulo
File: ChangeListManagerSerialization.java
File: ChangeListManagerSerialization.java
@SuppressWarnings({ "unchecked" }) public void readExternal(final Element element) throws InvalidDataException { final List<Element> listNodes = element.getChildren(NODE_LIST); for (Element listNode : listNodes) { readChangeList(listNode); } final List<Element> ignoredNodes = element.getChildren(NODE_IGNORED); for (Element ignoredNode : ignoredNodes) { readFileToIgnore(ignoredNode); } Element manuallyRemovedFromIgnoredTag = element.getChild(MANUALLY_REMOVED_FROM_IGNORED); Set<String> manuallyRemovedFromIgnoredPaths = new HashSet<String>(); if (manuallyRemovedFromIgnoredTag != null) { for (Element tag : manuallyRemovedFromIgnoredTag.getChildren(DIRECTORY_TAG)) { manuallyRemovedFromIgnoredPaths.add(tag.getAttributeValue(ATT_PATH)); } } myIgnoredIdeaLevel.setDirectoriesManuallyRemovedFromIgnored(manuallyRemovedFromIgnoredPaths); }
65. StudyTaskManager#getState()
Project: intellij-community
File: StudyTaskManager.java
File: StudyTaskManager.java
@Nullable @Override public Element getState() { if (myCourse == null) { return null; } Element el = new Element("taskManager"); Element courseElement = new Element(StudySerializationUtils.Xml.MAIN_ELEMENT); XmlSerializer.serializeInto(this, courseElement); el.addContent(courseElement); return el; }
66. YouTrackIntegrationTest#checkSpentTime()
Project: intellij-community
File: YouTrackIntegrationTest.java
File: YouTrackIntegrationTest.java
private void checkSpentTime(@NotNull HttpClient client, @NotNull String issueId, @NotNull String expectedTime) throws IOException, JDOMException { // Endpoint /rest/issue/BTYT4TT-8/timetracking/workitem/ doesn't work on this instance of YouTrack for some reason final GetMethod method = new GetMethod(myRepository.getUrl() + "/rest/issue/" + issueId); final int statusCode = client.executeMethod(method); assertEquals(HttpStatus.SC_OK, statusCode); final Element root = JDOMUtil.load(method.getResponseBodyAsStream()); for (Element field : root.getChildren("field")) { if ("Spent time".equals(field.getAttributeValue("name"))) { final Element value = field.getChild("value"); assertNotNull(value); assertEquals(expectedTime, value.getText().trim()); return; } } fail("Field 'Spent time' not found in issue " + issueId); }
67. DefaultArrangementSettingsSerializer#serialize()
Project: intellij-community
File: DefaultArrangementSettingsSerializer.java
File: DefaultArrangementSettingsSerializer.java
@Nullable public Element serialize(@NotNull ArrangementMatchRule rule) { Element matcherElement = myMatcherSerializer.serialize(rule.getMatcher()); if (matcherElement == null) { return null; } Element result = new Element(RULE_ELEMENT_NAME); result.addContent(new Element(MATCHER_ELEMENT_NAME).addContent(matcherElement)); if (rule.getOrderType() != ArrangementMatchRule.DEFAULT_ORDER_TYPE) { result.addContent(new Element(ORDER_TYPE_ELEMENT_NAME).setText(rule.getOrderType().getId())); } return result; }
68. PsiTestCase#loadData()
Project: intellij-community
File: PsiTestCase.java
File: PsiTestCase.java
private PsiTestData loadData(String dataName) throws Exception { PsiTestData data = createData(); Element documentElement = JdomKt.loadElement(Paths.get(myDataRoot, "data.xml")); for (Element node : documentElement.getChildren("data")) { String value = node.getAttributeValue("name"); if (value.equals(dataName)) { DefaultJDOMExternalizer.readExternal(data, node); data.loadText(myDataRoot); return data; } } throw new IllegalArgumentException("Cannot find data chunk '" + dataName + "'"); }
69. XMLUtilities#getServiceNotes()
Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
File: XMLUtilities.java
/** * * @param element * a full moby message (root element called MOBY) and may be * prefixed * @return the serviceNotes element if it exists, null otherwise. */ public static Element getServiceNotes(Element element) { Element serviceNotes = null; Element e = (Element) element.clone(); Element mobyContent = e.getChild("mobyContent"); if (mobyContent == null) mobyContent = e.getChild("mobyContent", MOBY_NS); // should throw exception? if (mobyContent == null) return serviceNotes; serviceNotes = mobyContent.getChild("serviceNotes"); if (serviceNotes == null) serviceNotes = mobyContent.getChild("serviceNotes", MOBY_NS); // note: servicenotes may be null return serviceNotes; }
70. XMLUtilities#getSimplesFromCollection()
Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
File: XMLUtilities.java
/** * * @param name * the name of the collection to extract the simples from. * @param element * the Element to extract from * @return an array of Elements objects that represent the simples * @throws MobyException */ public static Element[] getSimplesFromCollection(String name, Element element) throws MobyException { Element e = (Element) element.clone(); // exception thrown if not found Element collection = getCollection(name, e); List list = collection.getChildren("Simple"); if (list.isEmpty()) list = collection.getChildren("Simple", MOBY_NS); if (list.isEmpty()) return new Element[] {}; Vector vector = new Vector(); for (Iterator it = list.iterator(); it.hasNext(); ) { Object o = it.next(); if (o instanceof Element) { ((Element) o).setAttribute("articleName", name, MOBY_NS); if (((Element) o).getChildren().size() > 0) vector.add(o); } } Element[] elements = new Element[vector.size()]; vector.copyInto(elements); return elements; }
71. SlackNotificationMainConfig#getProxyAsElement()
Project: tcSlackBuildNotifier
File: SlackNotificationMainConfig.java
File: SlackNotificationMainConfig.java
public Element getProxyAsElement() { /* <proxy host="myproxy.mycompany.com" port="8080" > <noproxy url=".mycompany.com" /> <noproxy url="192.168.0." /> </proxy> */ if (this.getProxyHost() == null || this.getProxyPort() == null) { return null; } Element el = new Element(PROXY); el.setAttribute("host", this.getProxyHost()); el.setAttribute("port", String.valueOf(this.getProxyPort())); if (this.proxyPassword != null && this.proxyPassword.length() > 0 && this.proxyUsername != null && this.proxyUsername.length() > 0) { el.setAttribute(USERNAME, this.getProxyUsername()); el.setAttribute(PASSWORD, this.getProxyPassword()); } return el; }
72. SLAEventBean#getRegistrationEvent()
Project: oozie
File: SLAEventBean.java
File: SLAEventBean.java
private Element getRegistrationEvent(String tag) { Element eReg = new Element(tag); eReg.addContent(createATagElement("sequence-id", String.valueOf(getEvent_id()))); Element e = new Element("registration"); e.addContent(createATagElement("sla-id", getSlaId())); //e.addContent(createATagElement("sla-id", String.valueOf(getSlaId()))); e.addContent(createATagElement("app-type", getAppType().toString())); e.addContent(createATagElement("app-name", getAppName())); e.addContent(createATagElement("user", getUser())); e.addContent(createATagElement("group", getGroupName())); e.addContent(createATagElement("parent-sla-id", String.valueOf(getParentSlaId()))); e.addContent(createATagElement("expected-start", getDateString(getExpectedStart()))); e.addContent(createATagElement("expected-end", getDateString(getExpectedEnd()))); e.addContent(createATagElement("status-timestamp", getDateString(getStatusTimestamp()))); e.addContent(createATagElement("notification-msg", getNotificationMsg())); e.addContent(createATagElement("alert-contact", getAlertContact())); e.addContent(createATagElement("dev-contact", getDevContact())); e.addContent(createATagElement("qa-contact", getQaContact())); e.addContent(createATagElement("se-contact", getSeContact())); e.addContent(createATagElement("alert-percentage", getAlertPercentage())); e.addContent(createATagElement("alert-frequency", getAlertFrequency())); e.addContent(createATagElement("upstream-apps", getUpstreamApps())); e.addContent(createATagElement("job-status", getJobStatus().toString())); e.addContent(createATagElement("job-data", getJobData())); eReg.addContent(e); return eReg; }
73. TestActionStartXCommand#testActionReuseWfJobAppPath()
Project: oozie
File: TestActionStartXCommand.java
File: TestActionStartXCommand.java
public void testActionReuseWfJobAppPath() throws Exception { JPAService jpaService = Services.get().get(JPAService.class); WorkflowJobBean job = this.addRecordToWfJobTableWithCustomAppPath(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING); WorkflowActionBean action = this.addRecordToWfActionTableWithAppPathConfig(job.getId(), "1", WorkflowAction.Status.PREP); WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId()); new ActionStartXCommand(action.getId(), "map-reduce").call(); action = jpaService.execute(wfActionGetCmd); assertNotNull(action.getExternalId()); Element actionXml = XmlUtils.parseXml(action.getConf()); Namespace ns = actionXml.getNamespace(); Element configElem = actionXml.getChild("configuration", ns); String strConf = XmlUtils.prettyPrint(configElem).toString(); XConfiguration inlineConf = new XConfiguration(new StringReader(strConf)); String workDir = inlineConf.get("work.dir", null); assertNotNull(workDir); assertFalse(workDir.contains("workflow.xml")); }
74. TestCoordRerunXCommand#getActionXmlUrls()
Project: oozie
File: TestCoordRerunXCommand.java
File: TestCoordRerunXCommand.java
@SuppressWarnings("unchecked") private String[] getActionXmlUrls(Element eAction, String user, String group) { Element outputList = eAction.getChild("input-events", eAction.getNamespace()); for (Element data : (List<Element>) outputList.getChildren("data-in", eAction.getNamespace())) { if (data.getChild("uris", data.getNamespace()) != null) { String uris = data.getChild("uris", data.getNamespace()).getTextTrim(); if (uris != null) { String[] uriArr = uris.split(CoordELFunctions.INSTANCE_SEPARATOR); return uriArr; } } } return null; }
75. TestCoordRerunCommand#getActionXmlUrls()
Project: oozie
File: TestCoordRerunCommand.java
File: TestCoordRerunCommand.java
@SuppressWarnings("unchecked") private String[] getActionXmlUrls(Element eAction, String user, String group) { Element outputList = eAction.getChild("input-events", eAction.getNamespace()); for (Element data : (List<Element>) outputList.getChildren("data-in", eAction.getNamespace())) { if (data.getChild("uris", data.getNamespace()) != null) { String uris = data.getChild("uris", data.getNamespace()).getTextTrim(); if (uris != null) { String[] uriArr = uris.split(CoordELFunctions.INSTANCE_SEPARATOR); return uriArr; } } } return null; }
76. SubmitXCommand#verifySlaElements()
Project: oozie
File: SubmitXCommand.java
File: SubmitXCommand.java
private String verifySlaElements(Element eWfJob, ELEvaluator evalSla) throws CommandException { String jobSlaXml = ""; // Validate WF job Element eSla = eWfJob.getChild("info", Namespace.getNamespace(SchemaService.SLA_NAME_SPACE_URI)); if (eSla != null) { jobSlaXml = resolveSla(eSla, evalSla); } // Validate all actions for (Element action : (List<Element>) eWfJob.getChildren("action", eWfJob.getNamespace())) { eSla = action.getChild("info", Namespace.getNamespace(SchemaService.SLA_NAME_SPACE_URI)); if (eSla != null) { resolveSla(eSla, evalSla); } } return jobSlaXml; }
77. SubmitCommand#verifySlaElements()
Project: oozie
File: SubmitCommand.java
File: SubmitCommand.java
private String verifySlaElements(Element eWfJob, ELEvaluator evalSla) throws CommandException { String jobSlaXml = ""; // String prefix = XmlUtils.getNamespacePrefix(eWfJob, // SchemaService.SLA_NAME_SPACE_URI); // Validate WF job Element eSla = eWfJob.getChild("info", Namespace.getNamespace(SchemaService.SLA_NAME_SPACE_URI)); if (eSla != null) { jobSlaXml = resolveSla(eSla, evalSla); } // Validate all actions for (Element action : (List<Element>) eWfJob.getChildren("action", eWfJob.getNamespace())) { eSla = action.getChild("info", Namespace.getNamespace(SchemaService.SLA_NAME_SPACE_URI)); if (eSla != null) { resolveSla(eSla, evalSla); } } return jobSlaXml; }
78. CoordSubmitXCommand#includeDataSets()
Project: oozie
File: CoordSubmitXCommand.java
File: CoordSubmitXCommand.java
/** * Include referred datasets into XML. * * @param resolvedXml : Job XML element. * @param conf : Job configuration * @throws CoordinatorJobException thrown if failed to include referred datasets into XML */ @SuppressWarnings("unchecked") protected void includeDataSets(Element resolvedXml, Configuration conf) throws CoordinatorJobException { Element datasets = resolvedXml.getChild("datasets", resolvedXml.getNamespace()); Element allDataSets = new Element("all_datasets", resolvedXml.getNamespace()); List<String> dsList = new ArrayList<String>(); if (datasets != null) { for (Element includeElem : (List<Element>) datasets.getChildren("include", datasets.getNamespace())) { String incDSFile = includeElem.getTextTrim(); includeOneDSFile(incDSFile, dsList, allDataSets, datasets.getNamespace()); } for (Element e : (List<Element>) datasets.getChildren("dataset", datasets.getNamespace())) { String dsName = e.getAttributeValue("name"); if (dsList.contains(dsName)) { // Override with this DS // Remove old DS removeDataSet(allDataSets, dsName); } else { dsList.add(dsName); } allDataSets.addContent((Element) e.clone()); } } insertDataSet(resolvedXml, allDataSets); resolvedXml.removeChild("datasets", resolvedXml.getNamespace()); }
79. CoordSubmitXCommand#insertDataSet()
Project: oozie
File: CoordSubmitXCommand.java
File: CoordSubmitXCommand.java
/** * Insert data set into data-in and data-out tags. * * @param eAppXml : coordinator application XML * @param eDatasets : DataSet XML */ @SuppressWarnings("unchecked") private void insertDataSet(Element eAppXml, Element eDatasets) { // Adding DS definition in the coordinator XML Element inputList = eAppXml.getChild("input-events", eAppXml.getNamespace()); if (inputList != null) { for (Element dataIn : (List<Element>) inputList.getChildren("data-in", eAppXml.getNamespace())) { Element eDataset = findDataSet(eDatasets, dataIn.getAttributeValue("dataset")); dataIn.getContent().add(0, eDataset); } } Element outputList = eAppXml.getChild("output-events", eAppXml.getNamespace()); if (outputList != null) { for (Element dataOut : (List<Element>) outputList.getChildren("data-out", eAppXml.getNamespace())) { Element eDataset = findDataSet(eDatasets, dataOut.getAttributeValue("dataset")); dataOut.getContent().add(0, eDataset); } } }
80. CoordSubmitCommand#insertDataSet()
Project: oozie
File: CoordSubmitCommand.java
File: CoordSubmitCommand.java
/** * Insert data set into data-in and data-out tags. * * @param eAppXml : coordinator application XML * @param eDatasets : DataSet XML * @return updated application */ private void insertDataSet(Element eAppXml, Element eDatasets) { // Adding DS definition in the coordinator XML Element inputList = eAppXml.getChild("input-events", eAppXml.getNamespace()); if (inputList != null) { for (Element dataIn : (List<Element>) inputList.getChildren("data-in", eAppXml.getNamespace())) { Element eDataset = findDataSet(eDatasets, dataIn.getAttributeValue("dataset")); dataIn.getContent().add(0, eDataset); } } Element outputList = eAppXml.getChild("output-events", eAppXml.getNamespace()); if (outputList != null) { for (Element dataOut : (List<Element>) outputList.getChildren("data-out", eAppXml.getNamespace())) { Element eDataset = findDataSet(eDatasets, dataOut.getAttributeValue("dataset")); dataOut.getContent().add(0, eDataset); } } }
81. WindowManagerImpl#loadState()
Project: consulo
File: WindowManagerImpl.java
File: WindowManagerImpl.java
@Override public void loadState(Element state) { final Element frameElement = state.getChild(FRAME_ELEMENT); if (frameElement != null) { myFrameBounds = loadFrameBounds(frameElement); try { myFrameExtendedState = Integer.parseInt(frameElement.getAttributeValue(EXTENDED_STATE_ATTR)); if ((myFrameExtendedState & Frame.ICONIFIED) > 0) { myFrameExtendedState = Frame.NORMAL; } } catch (NumberFormatException ignored) { myFrameExtendedState = Frame.NORMAL; } } final Element desktopElement = state.getChild(DesktopLayout.TAG); if (desktopElement != null) { myLayout.readExternal(desktopElement); } }
82. ProjectManagerImpl#getState()
Project: consulo
File: ProjectManagerImpl.java
File: ProjectManagerImpl.java
@Nullable @Override public Element getState() { if (myDefaultProject != null) { myDefaultProject.save(); } if (myDefaultProjectRootElement == null) { // we are not ready to save return null; } Element element = new Element("state"); myDefaultProjectRootElement.detach(); element.addContent(myDefaultProjectRootElement); return element; }
83. HistoryEntry#writeExternal()
Project: consulo
File: HistoryEntry.java
File: HistoryEntry.java
/** * @return element that was added to the <code>element</code>. * Returned element has tag {@link #TAG}. Never null. */ public Element writeExternal(Element element, Project project) { Element e = new Element(TAG); element.addContent(e); e.setAttribute(FILE_ATTR, myFile.getUrl()); for (final Map.Entry<FileEditorProvider, FileEditorState> entry : myProvider2State.entrySet()) { FileEditorProvider provider = entry.getKey(); Element providerElement = new Element(PROVIDER_ELEMENT); if (provider.equals(mySelectedProvider)) { providerElement.setAttribute(SELECTED_ATTR_VALUE, Boolean.TRUE.toString()); } providerElement.setAttribute(EDITOR_TYPE_ID_ATTR, provider.getEditorTypeId()); Element stateElement = new Element(STATE_ELEMENT); providerElement.addContent(stateElement); provider.writeState(entry.getValue(), project, stateElement); e.addContent(providerElement); } return e; }
84. NotificationSettings#save()
Project: consulo
File: NotificationSettings.java
File: NotificationSettings.java
@NotNull public Element save() { final Element result = new Element("notification"); result.setAttribute("groupId", getGroupId()); final NotificationDisplayType displayType = getDisplayType(); if (displayType != NotificationDisplayType.BALLOON) { result.setAttribute("displayType", displayType.toString()); } if (!myShouldLog) { result.setAttribute("shouldLog", "false"); } if (myShouldReadAloud) { result.setAttribute("shouldReadAloud", "true"); } return result; }
85. ModuleExtensionImpl#getState()
Project: consulo
File: ModuleExtensionImpl.java
File: ModuleExtensionImpl.java
@Nullable @Override public final Element getState() { if (!isEnabled()) { return null; } Element element = new Element("extension"); element.setAttribute("id", myId); getStateImpl(element); return element; }
86. CopyrightManager#readExternal()
Project: consulo
File: CopyrightManager.java
File: CopyrightManager.java
private void readExternal(Element element) throws InvalidDataException { clearCopyrights(); final Element module2copyright = element.getChild(MODULE2COPYRIGHT); if (module2copyright != null) { for (Element o : module2copyright.getChildren(ELEMENT)) { final String moduleName = o.getAttributeValue(MODULE); final String copyrightName = o.getAttributeValue(COPYRIGHT); myModule2Copyrights.put(moduleName, copyrightName); } } for (Element o : element.getChildren(COPYRIGHT)) { final CopyrightProfile copyrightProfile = new CopyrightProfile(); copyrightProfile.readExternal(o); myCopyrights.put(copyrightProfile.getName(), copyrightProfile); } myDefaultCopyright = myCopyrights.get(element.getAttributeValue(DEFAULT)); myCopyrightFileConfigManager.readExternal(element); }
87. DefaultArrangementSettingsSerializer#deserializeTokensDefinition()
Project: consulo
File: DefaultArrangementSettingsSerializer.java
File: DefaultArrangementSettingsSerializer.java
@Nullable private Set<StdArrangementRuleAliasToken> deserializeTokensDefinition(@NotNull Element element, @NotNull ArrangementSettings defaultSettings) { if (!(defaultSettings instanceof ArrangementExtendableSettings)) { return null; } final Element tokensRoot = element.getChild(TOKENS_ELEMENT_NAME); if (tokensRoot == null) { return ((ArrangementExtendableSettings) myDefaultSettings).getRuleAliases(); } final Set<StdArrangementRuleAliasToken> tokenDefinitions = new THashSet<StdArrangementRuleAliasToken>(); final List<Element> tokens = tokensRoot.getChildren(TOKEN_ELEMENT_NAME); for (Element token : tokens) { final Attribute id = token.getAttribute(TOKEN_ID); final Attribute name = token.getAttribute(TOKEN_NAME); assert id != null && name != null : "Can not find id for token: " + token; final Element rules = token.getChild(RULES_ELEMENT_NAME); final List<StdArrangementMatchRule> tokenRules = rules == null ? ContainerUtil.<StdArrangementMatchRule>emptyList() : deserializeRules(rules, null); tokenDefinitions.add(new StdArrangementRuleAliasToken(id.getValue(), name.getValue(), tokenRules)); } return tokenDefinitions; }
88. ExtensionComponentAdapterTest#readElement()
Project: consulo
File: ExtensionComponentAdapterTest.java
File: ExtensionComponentAdapterTest.java
static Element readElement(String text) { Element extensionElement1 = null; try { extensionElement1 = new SAXBuilder().build(new StringReader(text)).getRootElement(); } catch (JDOMException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } Element extensionElement = extensionElement1; return extensionElement; }
89. ResourceCompilerConfiguration#getState()
Project: consulo
File: ResourceCompilerConfiguration.java
File: ResourceCompilerConfiguration.java
@Nullable @Override public Element getState() { Element parentNode = new Element("state"); final Element newChild = addChild(parentNode, RESOURCE_EXTENSIONS); for (final String pattern : getRegexpPatterns()) { addChild(newChild, ENTRY).setAttribute(NAME, pattern); } if (myWildcardPatternsInitialized || !myWildcardPatterns.isEmpty()) { final Element wildcardPatterns = addChild(parentNode, WILDCARD_RESOURCE_PATTERNS); for (final String wildcardPattern : myWildcardPatterns) { addChild(wildcardPatterns, ENTRY).setAttribute(NAME, wildcardPattern); } } return parentNode; }
90. ArtifactManagerImpl#serializePackagingElement()
Project: consulo
File: ArtifactManagerImpl.java
File: ArtifactManagerImpl.java
private static Element serializePackagingElement(PackagingElement<?> packagingElement) { Element element = new Element(PACKAGING_ELEMENT_NAME); element.setAttribute(TYPE_ID_ATTRIBUTE, packagingElement.getType().getId()); final Object bean = packagingElement.getState(); if (bean != null) { XmlSerializer.serializeInto(bean, element, new SkipDefaultValuesSerializationFilters()); } if (packagingElement instanceof CompositePackagingElement) { for (PackagingElement<?> child : ((CompositePackagingElement<?>) packagingElement).getChildren()) { element.addContent(serializePackagingElement(child)); } } return element; }
91. CompilerConfigurationImpl#getState()
Project: consulo
File: CompilerConfigurationImpl.java
File: CompilerConfigurationImpl.java
@Nullable @Override public Element getState() { if (myOutputDirPointer == null) { return null; } Element element = new Element("state"); element.setAttribute(URL, myOutputDirPointer.getUrl()); for (Module module : myModuleManager.getModules()) { val moduleCompilerPathsManager = (ModuleCompilerPathsManagerImpl) ModuleCompilerPathsManager.getInstance(module); Element state = moduleCompilerPathsManager.getState(); if (state != null) { element.addContent(state); } } return element; }
92. InspectionProfileLoadUtil#load()
Project: consulo
File: InspectionProfileLoadUtil.java
File: InspectionProfileLoadUtil.java
@NotNull public static Profile load(@NotNull File file, @NotNull InspectionToolRegistrar registrar, @NotNull ProfileManager profileManager) throws JDOMException, IOException, InvalidDataException { Element element = JDOMUtil.loadDocument(file).getRootElement(); InspectionProfileImpl profile = new InspectionProfileImpl(getProfileName(file, element), registrar, profileManager); final Element profileElement = element.getChild(PROFILE_TAG); if (profileElement != null) { element = profileElement; } profile.readExternal(element); return profile; }
93. InspectionProfileConvertor#convertToNewFormat()
Project: consulo
File: InspectionProfileConvertor.java
File: InspectionProfileConvertor.java
public static Element convertToNewFormat(Element profileFile, InspectionProfile profile) { Element rootElement = new Element(INSPECTIONS_TAG); rootElement.setAttribute(NAME_ATT, profile.getName()); final InspectionToolWrapper[] tools = profile.getInspectionTools(null); for (final Object o : profileFile.getChildren(INSP_TOOL_TAG)) { Element toolElement = ((Element) o).clone(); String toolClassName = toolElement.getAttributeValue(CLASS_ATT); final String shortName = convertToShortName(toolClassName, tools); if (shortName == null) { continue; } toolElement.setAttribute(CLASS_ATT, shortName); rootElement.addContent(toolElement); } return rootElement; }
94. XMLUtilities#getListOfCollections()
Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
File: XMLUtilities.java
/** * * @param message * the String to extract the list of collections from and assumes * that you are passing in a single invocation message. * @return an array of Strings representing all of the fully 'wrapped' * collections in the message. * @throws MobyException * if the the element contains an invalid BioMOBY message */ public static String[] getListOfCollections(String message) throws MobyException { Element element = getDOMDocument(message).getRootElement(); Element[] elements = getListOfCollections(element); String[] strings = new String[elements.length]; XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(false)); for (int count = 0; count < elements.length; count++) { try { strings[count] = outputter.outputString(elements[count]); } catch (Exception e) { throw new MobyException(newline + "Unexpected error occured while creating String[]:" + newline + Utils.format(e.getLocalizedMessage(), 3)); } } return strings; }
95. XMLUtilities#getListOfSimples()
Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
File: XMLUtilities.java
/** * * @param message * the String of xml to extract the list of simples from. This * method assumes that you are passing in a single invokation and * that you wish to extract the Simples not contained in any * collections. This method also maintains any past queryIDs. * @return an array of Strings that represent fully 'wrapped' simples. * @throws MobyException * if the String doesnt contain a structurally valid Moby * message structure or if an unexpected error occurs */ public static String[] getListOfSimples(String message) throws MobyException { Element element = getDOMDocument(message).getRootElement(); Element[] elements = getListOfSimples(element); String[] strings = new String[elements.length]; XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(false)); for (int count = 0; count < elements.length; count++) { try { strings[count] = outputter.outputString(elements[count]); } catch (Exception e) { throw new MobyException(newline + "Unexpected error occured while creating String[]:" + newline + Utils.format(e.getLocalizedMessage(), 3)); } } return strings; }
96. QueryXMLHandler#elementToDataset()
Project: incubator-taverna-plugin-bioinformatics
File: QueryXMLHandler.java
File: QueryXMLHandler.java
/** * Creates a <code>Dataset</code> from an XML element. * * @param element * the <code>Element</code> to deserialize * @param namespace * the <code>Namespace</code> containing the * <code>Element</code> * @return a deserialized <code>Dataset</code> */ public static Dataset elementToDataset(Element element, Namespace namespace) { Dataset dataset = new Dataset(element.getAttributeValue(NAME_ATTRIBUTE)); List<Element> attributes = element.getChildren(ATTRIBUTE_ELEMENT, namespace); for (Element attributeElement : attributes) { dataset.addAttribute(elementToAttribute(attributeElement)); } List<Element> filters = element.getChildren(FILTER_ELEMENT, namespace); for (Element filterElement : filters) { dataset.addFilter(elementToFilter(filterElement)); } return dataset; }
97. QueryXMLHandler#elementToQuery()
Project: incubator-taverna-plugin-bioinformatics
File: QueryXMLHandler.java
File: QueryXMLHandler.java
/** * Creates a <code>Query</code> from an XML element. * * @param element * the <code>Element</code> to deserialize * @param namespace * the <code>Namespace</code> containing the * <code>Element</code> * @return a deserialized <code>Query</code> */ public static Query elementToQuery(Element element, Namespace namespace) { String virtualSchema = element.getAttributeValue(SCHEMA_ATTRIBUTE); int count = Integer.parseInt(element.getAttributeValue(COUNT_ATTRIBUTE)); String version = element.getAttributeValue(VERSION_ATTRIBUTE); String formatter = element.getAttributeValue(FORMATTER_ATTRIBUTE); String requestId = element.getAttributeValue(REQUEST_ID_ATTRIBUTE); Query query = new Query(virtualSchema, count, version, requestId); query.setFormatter(formatter); String uniqueRows = element.getAttributeValue(UNIQUE_ROWS_ATTRIBUTE); if (uniqueRows != null) { query.setUniqueRows(Integer.parseInt(uniqueRows)); } List<Element> datasets = element.getChildren(DATASET_ELEMENT, namespace); for (Element datasetElement : datasets) { query.addDataset(elementToDataset(datasetElement, namespace)); } List<Element> links = element.getChildren(LINK_ELEMENT, namespace); for (Element linkElement : links) { query.addLink(elementToLink(linkElement)); } return query; }
98. QueryXMLHandler#filterToElement()
Project: incubator-taverna-plugin-bioinformatics
File: QueryXMLHandler.java
File: QueryXMLHandler.java
/** * Converts a <code>Filter</code> to an XML element. * * @param filter * the <code>Filter</code> to serialize * @param namespace * the <code>Namespace</code> to use when constructing the * <code>Element</code> * @return an XML serialization of the <code>Filter</code> */ public static Element filterToElement(Filter filter, Namespace namespace) { Element filterElement = new Element(FILTER_ELEMENT, namespace); filterElement.setAttribute(NAME_ATTRIBUTE, filter.getName()); String value = filter.getValue(); if (filter.isBoolean()) { if ("excluded".equalsIgnoreCase(value)) { filterElement.setAttribute("excluded", "1"); } else { filterElement.setAttribute("excluded", "0"); } } else { if (value == null) { filterElement.setAttribute("value", ""); } else { filterElement.setAttribute("value", value); } } if (filter.isList()) { filterElement.setAttribute("list", "true"); } return filterElement; }
99. QueryXMLHandler#datasetToElement()
Project: incubator-taverna-plugin-bioinformatics
File: QueryXMLHandler.java
File: QueryXMLHandler.java
/** * Converts a <code>Dataset</code> to an XML element. * * @param dataset * the <code>Dataset</code> to serialize * @param namespace * the <code>Namespace</code> to use when constructing the * <code>Element</code> * @return an XML serialization of the <code>Dataset</code> */ public static Element datasetToElement(Dataset dataset, Namespace namespace) { Element datasetElement = new Element(DATASET_ELEMENT, namespace); datasetElement.setAttribute(NAME_ATTRIBUTE, dataset.getName()); for (Attribute attribute : dataset.getAttributes()) { datasetElement.addContent(attributeToElement(attribute, namespace)); } for (Filter filter : dataset.getFilters()) { datasetElement.addContent(filterToElement(filter, namespace)); } return datasetElement; }
100. ProvenanceQuery#addToCollection()
Project: incubator-taverna-engine
File: ProvenanceQuery.java
File: ProvenanceQuery.java
private void addToCollection(LineageQueryResultRecord record, Document d) { Element root = d.getRootElement(); String[] itVector = record.getIteration().split(","); Element currentEl = root; // each element gives us a corresponding child in the tree for (int i = 0; i < itVector.length; i++) { int index = Integer.parseInt(itVector[i]); List<?> children = currentEl.getChildren(); if (index < children.size()) currentEl = (Element) children.get(index); else if (i == itVector.length - 1) currentEl.addContent(new Element(record.getValue())); else currentEl.addContent(new Element("list")); } }