package org.grobid.service.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import org.grobid.core.utilities.GrobidProperties;
import org.grobid.core.utilities.GrobidPropertyKeys;
import org.grobid.core.utilities.XmlUtils;

/**
 * Utility methods for managing Grobid properties.
 * 
 * @author Damien
 * 
 */
public class GrobidPropertiesUtil {

	/**
	 * Return a list of {@link GrobidProperty} containing all the properties of
	 * Grobid.
	 * 
	 * @return List<GrobidProperty>
	 */
	public static List<GrobidProperty> getAllPropertiesList() {
		List<GrobidProperty> gbdProperties = new ArrayList<GrobidProperty>();
		Properties props = GrobidServiceProperties.getProps();
		for (Object property : props.keySet()) {
			final String currProperty = (String) property;
			gbdProperties.add(new GrobidProperty(currProperty, props
					.getProperty(currProperty)));
		}
		props = GrobidProperties.getProps();
		for (Object property : props.keySet()) {
			final String currProperty = (String) property;
			gbdProperties.add(new GrobidProperty(currProperty, props
					.getProperty(currProperty)));
		}
		return gbdProperties;
	}

	/**
	 * Build an xml representation of all grobid properties.
	 * 
	 * @return String
	 */
	public static String getAllPropertiesListXml() {
		StringBuilder gbdProperties = new StringBuilder();
		gbdProperties.append(XmlUtils.startTag("properties"));
		for (GrobidProperty currProp : getAllPropertiesList()) {
			if(!GrobidPropertyKeys.PROP_GROBID_IS_CONTEXT_SERVER.equals(currProp.getKey())){
				gbdProperties.append(currProp.toString());
			}
		}
		gbdProperties.append(XmlUtils.endTag("properties"));
		return gbdProperties.toString();
	}

}

@@ -849,38 +849,32 @@
 rProperty, props
-%0A%09%09%09%09%09
 .getProperty(cur
@@ -1086,14 +1086,8 @@
 rops
-%0A%09%09%09%09%09
 .get
@@ -1460,16 +1460,17 @@
  %7B%0A%09%09%09if
+ 
 (!Grobid
@@ -1538,16 +1538,17 @@
 tKey()))
+ 
 %7B%0A%09%09%09%09gb

Formatting.