Java Code Examples for org.jdom.output.Format#setIndent()

The following examples show how to use org.jdom.output.Format#setIndent() . 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: EntityTypeDOM.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public String getXml(IApsEntity entityType) throws ApsSystemException {
	XMLOutputter out = new XMLOutputter();
	Document document = new Document();
	try {
		Element entityTypeElement = this.createTypeElement(entityType);
		document.setRootElement(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 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(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 3
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 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: 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 6
Source File: SystemParamsUtils.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static String getXMLDocument(Document doc) {
    XMLOutputter out = new XMLOutputter();
    Format format = Format.getPrettyFormat();
    format.setIndent("\t");
    out.setFormat(format);
    return out.outputString(doc);
}
 
Example 7
Source File: PageModelDOM.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(this._doc);
}
 
Example 8
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 9
Source File: GenericXMLOutputter.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void init() {
    // this prevents an excess build up of whitespace
    Format compactFormat = Format.getCompactFormat();
    compactFormat.setIndent( DEFAULT_INDENT );
    compactFormat.setTextMode( TextMode.NORMALIZE );
    setFormat( compactFormat );
}
 
Example 10
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 11
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 12
Source File: MailConfigDOM.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Create an xml containing the jpmail configuration.
 * @param config The jpmail configuration.
 * @return The xml containing the configuration.
 * @throws ApsSystemException In case of errors.
 */
public String createConfigXml(MailConfig 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: 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 14
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 15
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 16
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 17
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);
	}
}