Package jetbrains.buildServer.util
Class PropertiesUtil
- java.lang.Object
-
- jetbrains.buildServer.util.PropertiesUtil
-
public class PropertiesUtil extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcompareProperties(Map<String,String> props1, Map<String,String> props2)Compares 2 maps of properties.static booleangetBoolean(String value)static Set<String>getPropertyNames(Properties properties)static byte[]getUpdatedPropertiesArray(File propertiesFile, Properties newProperties)Reads thepropertiesFileproperties, updates them with thenewPropertiesand returns the byte array of the result with ISO-8859-1 encoding.static byte[]getUpdatedPropertiesArray(File propertiesFile, Properties newProperties, String commentIfFileIsRecreated)static booleanisDifferent(Properties p1, Properties p2)static booleanisEmptyOrNull(String value)static PropertiesloadProperties(File propertiesFile)static PropertiesloadProperties(InputStream inputStream)Load properties and closes the streamstatic PropertiesloadPropertiesXml(File propertiesFile)static PropertiesloadPropertiesZipped(File propertiesFile)static IntegerparseInt(String value)static LongparseLong(String value)static voidstoreProperties(Properties properties, File propertiesFile, String comment)static voidstoreProperties(Properties properties, OutputStream stream, String comment)static voidstorePropertiesXml(Properties properties, File propertiesFile, String comment)static voidstorePropertiesZipped(Properties properties, File propertiesFile, String comment)static Map<String,String>toMap(Properties properties)static booleanupdateProperties(File propertiesFile, Properties newProperties, String commentIfFileIsRecreated)static booleanupdatePropertiesFromFile(File propertiesFile, Map<String,String> propertiesToUpdate, Set<String> toRemove)Updates properties file with respect to all comments, encodings
-
-
-
Method Detail
-
getBoolean
@Contract("null -> false") public static boolean getBoolean(@Nullable String value)
-
isEmptyOrNull
@Contract("null -> true") public static boolean isEmptyOrNull(@Nullable String value)
-
parseInt
@Contract("null -> null") @Nullable public static Integer parseInt(@Nullable String value)
-
compareProperties
public static int compareProperties(@NotNull Map<String,String> props1, @NotNull Map<String,String> props2)Compares 2 maps of properties. a=b compared to a=b&c=d will return -1; a=b&c=d compared to empty map will return 1; a=b compared to c=d will return 0;- Parameters:
props1- the first mapprops2- the second map- Returns:
- >0, if props1 is more specific properties set than props2, <0, if less specific, 0 if the difference cannot be determined
-
loadProperties
@NotNull public static Properties loadProperties(File propertiesFile) throws IOException
- Throws:
IOException
-
loadPropertiesZipped
@NotNull public static Properties loadPropertiesZipped(File propertiesFile) throws IOException
- Throws:
IOException
-
loadProperties
@NotNull public static Properties loadProperties(@Nullable InputStream inputStream) throws IOException
Load properties and closes the stream- Parameters:
inputStream- stream- Returns:
- loaded properties file
- Throws:
IOException
-
loadPropertiesXml
@NotNull public static Properties loadPropertiesXml(File propertiesFile) throws IOException
- Throws:
IOException
-
toMap
@NotNull public static Map<String,String> toMap(@NotNull Properties properties)
-
storeProperties
public static void storeProperties(@NotNull Properties properties, @Nullable File propertiesFile, @Nullable String comment) throws IOException- Throws:
IOException
-
storePropertiesZipped
public static void storePropertiesZipped(@NotNull Properties properties, @Nullable File propertiesFile, @Nullable String comment) throws IOException- Throws:
IOException
-
storeProperties
public static void storeProperties(@NotNull Properties properties, @Nullable OutputStream stream, @Nullable String comment) throws IOException- Throws:
IOException
-
storePropertiesXml
public static void storePropertiesXml(@NotNull Properties properties, @Nullable File propertiesFile, @Nullable String comment) throws IOException- Throws:
IOException
-
isDifferent
public static boolean isDifferent(@NotNull Properties p1, @NotNull Properties p2)
-
getPropertyNames
@NotNull public static Set<String> getPropertyNames(@NotNull Properties properties)
-
updatePropertiesFromFile
public static boolean updatePropertiesFromFile(@NotNull File propertiesFile, @NotNull Map<String,String> propertiesToUpdate, @NotNull Set<String> toRemove) throws IOExceptionUpdates properties file with respect to all comments, encodings- Parameters:
propertiesFile- filepropertiesToUpdate- properties to updatetoRemove- property names to remove. Those properties will be commented out form the file- Returns:
- true if file was changed, false otherwise
- Throws:
IOException- in error
-
updateProperties
public static boolean updateProperties(@NotNull File propertiesFile, @NotNull Properties newProperties, @Nullable String commentIfFileIsRecreated) throws IOException- Throws:
IOException
-
getUpdatedPropertiesArray
@Nullable public static byte[] getUpdatedPropertiesArray(@NotNull File propertiesFile, @NotNull Properties newProperties) throws IOExceptionReads thepropertiesFileproperties, updates them with thenewPropertiesand returns the byte array of the result with ISO-8859-1 encoding.- Throws:
IOException
-
getUpdatedPropertiesArray
@Nullable public static byte[] getUpdatedPropertiesArray(@NotNull File propertiesFile, @NotNull Properties newProperties, @Nullable String commentIfFileIsRecreated) throws IOException- Throws:
IOException
-
-