Java Code Examples for org.jdom.output.XMLOutputter#outputString()

The following examples show how to use org.jdom.output.XMLOutputter#outputString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StepConfigsDOM.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String createConfigXml(StepsConfig stepsConfig) throws ApsSystemException {
	String xml = null;
	try {
		Element root =  this.createConfigElement(stepsConfig);
		XMLOutputter out = new XMLOutputter();
		Format format = Format.getPrettyFormat();
		format.setIndent("\t");
		out.setFormat(format);
		Document doc = new Document(root);
		xml = out.outputString(doc);
	} catch (Throwable t) {
		_logger.error("Error creating xml config", t);
		throw new ApsSystemException("Error creating xml config", t);
	}
	return xml;
}
 
Example 2
Source File: StepConfigsDOM.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String createConfigXml(Map<String, StepsConfig> config) throws ApsSystemException {
	String xml = null;
	try {
		Element root = new Element(ROOT);
		Collection<StepsConfig> stepsConfigs = config.values();
		if (null != stepsConfigs) {
			Iterator<StepsConfig> iter = stepsConfigs.iterator();
			while (iter.hasNext()) {
				StepsConfig stepsConfig = iter.next();
				Element stepsConfigElements = this.createConfigElement(stepsConfig);
				root.addContent(stepsConfigElements);
			}
		}
		XMLOutputter out = new XMLOutputter();
		Format format = Format.getPrettyFormat();
		format.setIndent("\t");
		out.setFormat(format);
		Document doc = new Document(root);
		xml = out.outputString(doc);
	} catch (Throwable t) {
		_logger.error("Error creating xml config", t);
		throw new ApsSystemException("Error creating xml config", t);
	}
	return xml;
}
 
Example 3
Source File: EntityTypeDOM.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public String getXml(Map<String, IApsEntity> entityTypes) throws ApsSystemException {
	XMLOutputter out = new XMLOutputter();
	Document document = new Document();
	try {
		Element rootElement = new Element(this.getEntityTypesRootElementName());
		document.setRootElement(rootElement);
		List<String> entityTypeCodes = new ArrayList<>(entityTypes.keySet());
		Collections.sort(entityTypeCodes);
		for (String entityTypeCode : entityTypeCodes) {
			IApsEntity currentEntityType = entityTypes.get(entityTypeCode);
			Element entityTypeElement = this.createTypeElement(currentEntityType);
			rootElement.addContent(entityTypeElement);
		}
		Format format = Format.getPrettyFormat();
		format.setIndent("\t");
		out.setFormat(format);
	} catch (Throwable t) {
		_logger.error("Error building xml", t);
		throw new ApsSystemException("Error building xml", t);
	}
	return out.outputString(document);
}
 
Example 4
Source File: UserShortcutConfigDOM.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected static String createUserConfigXml(String[] config) throws ApsSystemException {
	XMLOutputter out = new XMLOutputter();
	Document document = new Document();
	try {
		Element rootElement = new Element(ROOT_ELEMENT_NAME);
		document.setRootElement(rootElement);
		for (int i = 0; i < config.length; i++) {
			String shortcut = config[i];
			if (null != shortcut) {
				Element element = new Element(BOX_ELEMENT_NAME);
				element.setAttribute(POS_ATTRIBUTE_NAME, String.valueOf(i));
				element.setText(shortcut);
				rootElement.addContent(element);
			}
		}
	} catch (Throwable t) {
		_logger.error("Error parsing user config", t);
		//ApsSystemUtils.logThrowable(t, UserShortcutConfigDOM.class, "extractUserShortcutConfig");
		throw new ApsSystemException("Error parsing user config", t);
	}
	Format format = Format.getPrettyFormat();
	format.setIndent("\t");
	out.setFormat(format);
	return out.outputString(document);
}
 
Example 5
Source File: WorkflowNotifierDOM.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String createConfigXml(NotifierConfig notifierConfig) throws ApsSystemException {
	Element root = new Element(ROOT);
	Element schedulerElement = this.prepareSchedulerElement(notifierConfig);
	root.addContent(schedulerElement);
	Element mailElement = this.prepareMailElement(notifierConfig);
	root.addContent(mailElement);
	
	XMLOutputter out = new XMLOutputter();
	String xml = out.outputString(new Document(root));
	return xml;
}
 
Example 6
Source File: ContentWorkflowDOM.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String createConfigXml(Map<String, Workflow> config) throws ApsSystemException {
	Element root = this.createConfigElement(config);
	Document doc = new Document(root);
	XMLOutputter out = new XMLOutputter();
	Format format = Format.getPrettyFormat();
	format.setIndent("\t");
	out.setFormat(format);
	return out.outputString(doc);
}
 
Example 7
Source File: SystemInstallationReport.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String toXml() {
    Document doc = new Document();
    Element rootElement = new Element(ROOT_ELEMENT);
    Status status = Status.OK;
    for (ComponentInstallationReport componentReport : this.getReports()) {
        if (!componentReport.getStatus().equals(Status.OK)
                && !componentReport.getStatus().equals(Status.UNINSTALLED)) {
            status = componentReport.getStatus();
            break;
        }
    }
    rootElement.setAttribute(STATUS_ATTRIBUTE, status.toString());

    Element creationElement = new Element(CREATION_ELEMENT);
    creationElement.setText(DateConverter.getFormattedDate(this.getCreation(), DATE_FORMAT));
    rootElement.addContent(creationElement);

    Element lastUpdateElement = new Element(LAST_UPDATE_ELEMENT);
    lastUpdateElement.setText(DateConverter.getFormattedDate(this.getLastUpdate(), DATE_FORMAT));
    rootElement.addContent(lastUpdateElement);

    Element componentsElement = new Element(COMPONENTS_ELEMENT);
    rootElement.addContent(componentsElement);
    for (int i = 0; i < this.getReports().size(); i++) {
        ComponentInstallationReport singleReport = this.getReports().get(i);
        Element componentElement = singleReport.toJdomElement();
        componentsElement.addContent(componentElement);
    }
    doc.setRootElement(rootElement);
    XMLOutputter out = new XMLOutputter();
    Format format = Format.getPrettyFormat();
    format.setIndent("\t");
    out.setFormat(format);
    return out.outputString(doc);
}
 
Example 8
Source File: WidgetTypeDOM.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String getXMLDocument(){
	XMLOutputter out = new XMLOutputter();
	Format format = Format.getPrettyFormat();
	format.setIndent("");
	out.setFormat(format);
	return out.outputString(this.getDoc());
}
 
Example 9
Source File: ApsPropertiesDOM.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Restituisce il formato xml delle Properties.
 * @return String Formato xml delle Properties.
 */
public String getXMLDocument(){
	XMLOutputter out = new XMLOutputter();
	Format format = Format.getPrettyFormat();
	format.setIndent("");
	out.setFormat(format);
	return out.outputString(_doc);
}
 
Example 10
Source File: NewsletterConfigDOM.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Create an xml containing the newsletter configuration.
 * @param config The newsletter configuration.
 * @return The xml containing the configuration.
 * @throws ApsSystemException In case of errors.
 */
public String createConfigXml(NewsletterConfig config) throws ApsSystemException {
	Element root = this.createConfigElement(config);
	Document doc = new Document(root);
	XMLOutputter out = new XMLOutputter();
	Format format = Format.getPrettyFormat();
	format.setIndent("\t");
	out.setFormat(format);
	String xml = out.outputString(doc);
	return xml;
}
 
Example 11
Source File: LangDOM.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Restutuisce l'xml del documento.
 * @return L'xml del documento.
 */
public String getXMLDocument(){
	XMLOutputter out = new XMLOutputter();
	Format format = Format.getPrettyFormat();
	out.setFormat(format);
	String xml = out.outputString(this.doc);
	return xml;
}
 
Example 12
Source File: AvatarConfigDOM.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Create an xml containing the jpavatar configuration.
 * @param config The jpavatar configuration.
 * @return The xml containing the configuration.
 * @throws ApsSystemException In case of errors.
 */
public String createConfigXml(AvatarConfig config) throws ApsSystemException {
	Element root = this.createConfigElement(config);
	Document doc = new Document(root);
	XMLOutputter out = new XMLOutputter();
	Format format = Format.getPrettyFormat();
	format.setIndent("\t");
	out.setFormat(format);
	return out.outputString(doc);
}
 
Example 13
Source File: ApsEntityDOM.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Return the XML structure of the entity.
 * @return String The XML structure of the entity.
 */
@Override
public String getXMLDocument(){
	XMLOutputter out = new XMLOutputter();
	String xml = out.outputString(_doc);
	return xml;
}
 
Example 14
Source File: ShortcutDefDOM.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String getXMLDocument(){
	XMLOutputter out = new XMLOutputter();
	Format format = Format.getPrettyFormat();
	format.setIndent("\t");
	out.setFormat(format);
	return out.outputString(_doc);
}
 
Example 15
Source File: PageExtraConfigDOM.java    From entando-core with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected String getXMLDocument(Document doc) {
	XMLOutputter out = new XMLOutputter();
	Format format = Format.getPrettyFormat();
	out.setFormat(format);
	return out.outputString(doc);
}
 
Example 16
Source File: ResourceDOM.java    From entando-components with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Restituisce la stringa xml corrispondente alla risorsa.
 *
 * @return La stringa xml corrispondente alla risorsa.
 */
public String getXMLDocument() {
    XMLOutputter out = new XMLOutputter();
    String xml = out.outputString(this._doc);
    return xml;
}
 
Example 17
Source File: ServiceExtraConfigDOM.java    From entando-core with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected String getXMLDocument() {
    XMLOutputter out = new XMLOutputter();
    Format format = Format.getPrettyFormat();
    out.setFormat(format);
    return out.outputString(this._doc);
}
 
Example 18
Source File: DataSourceDumpReport.java    From entando-core with GNU Lesser General Public License v3.0 4 votes vote down vote up
public String toXml() {
	try {
		Document doc = new Document();
		Element rootElement = new Element(ROOT_ELEMENT);
		this.addElement(DATE_ELEMENT, DateConverter.getFormattedDate(this.getDate(), DATE_FORMAT), rootElement);
		this.addElement(REQUIRED_TIME_ELEMENT, String.valueOf(this.getRequiredTime()), rootElement);
		this.addElement(SUBFOLDER_NAME_ELEMENT, this.getSubFolderName(), rootElement);
		Element components = new Element(COMPONENTS_HISTORY_ELEMENT);
		rootElement.addContent(components);
		List<ComponentInstallationReport> componentsHistory = this.getComponentsHistory();
		for (int i = 0; i < componentsHistory.size(); i++) {
			ComponentInstallationReport componentHistory = componentsHistory.get(i);
			Element element = componentHistory.toJdomElement();
			components.addContent(element);
		}
		List<String> dataSourceNames = new ArrayList<String>();
		dataSourceNames.addAll(this.getDataSourcesReports().keySet());
		for (int i = 0; i < dataSourceNames.size(); i++) {
			String dataSourceName = dataSourceNames.get(i);
			Element dataSourceElement = new Element(DATASOURCE_ELEMENT);
			rootElement.addContent(dataSourceElement);
			dataSourceElement.setAttribute(NAME_ATTRIBUTE, dataSourceName);
			List<TableDumpReport> tableReports = this.getDataSourcesReports().get(dataSourceName);
			BeanComparator comparator = new BeanComparator("tableName");
			Collections.sort(tableReports, comparator);
			for (int j = 0; j < tableReports.size(); j++) {
				TableDumpReport tableDumpReport = tableReports.get(j);
				dataSourceElement.addContent(tableDumpReport.toJdomElement());
			}
		}
		doc.setRootElement(rootElement);
		XMLOutputter out = new XMLOutputter();
		Format format = Format.getPrettyFormat();
		format.setIndent("\t");
		out.setFormat(format);
		return out.outputString(doc);
	} catch (Throwable t) {
		_logger.error("Error creating XML", t);
		throw new RuntimeException("Error creating XML", t);
	}
}
 
Example 19
Source File: TopographicalMap.java    From beast-mcmc with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static String mapToXMLString(double[][] map, int numLevels) {
        XMLOutputter outputter = new XMLOutputter(org.jdom.output.Format.getPrettyFormat());
        return outputter.outputString(mapToXML(map, numLevels));
//				root.toString();
    }
 
Example 20
Source File: XmlUtilities.java    From ghidra with Apache License 2.0 2 votes vote down vote up
/**
 * Converts the specified XML element into a String.
 * 
 * @param root the root element
 * @return String translation of the given element
 */
public static String toString(Element root) {
	XMLOutputter outputter = new GenericXMLOutputter();
	return outputter.outputString(root);
}