Package net.shibboleth.idp.installer
Class PropertiesWithComments
- java.lang.Object
-
- net.shibboleth.idp.installer.PropertiesWithComments
-
public final class PropertiesWithComments extends Object
A package which is similar to Properties, but allows comments to be preserved. We use the Properties package to parse the non-comment lines.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classPropertiesWithComments.CommentedPropertyA POJO which looks like a property.
-
Field Summary
Fields Modifier and Type Field Description private List<Object>contentsThe contents.private booleanloadedDataHave we loaded data?.private PropertiesnameReplacementName Replacement info.private Map<String,PropertiesWithComments.CommentedProperty>propertiesThe properties bit.private Set<String>unreplacableNamesBlackListed property names.
-
Constructor Summary
Constructors Constructor Description PropertiesWithComments()Legacy Constructor.PropertiesWithComments(Set<String> unreplacable)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddComment(String what)Append a comment to the list.private voidaddCommentedProperty(String line, boolean isComment)Add a property, either as a key/value pair or as a key/comment pair.voidload(InputStream input)Read the input stream into our structures.voidloadNameReplacement(InputStream input)Read the name replacement data.voidreplaceProperties(Properties replacements)Perform a mass replacement from the suppliedProperties.booleanreplaceProperty(String propName, String newPropValue)Replace the supplied property or stuff it at the bottom of the list.voidstore(OutputStream output)Put the output to the supplied stream.
-
-
-
Field Detail
-
contents
private List<Object> contents
The contents. EachObjectis either a string (a non-property line) or aPropertiesWithComments.CommentedProperty(an optionally commented property definition).
-
properties
private Map<String,PropertiesWithComments.CommentedProperty> properties
The properties bit.
-
nameReplacement
private final Properties nameReplacement
Name Replacement info.
-
loadedData
private boolean loadedData
Have we loaded data?. We cannot load the replacement names after the file load.
-
-
Method Detail
-
addCommentedProperty
private void addCommentedProperty(@Nonnull @NotEmpty String line, boolean isComment) throws IOException
Add a property, either as a key/value pair or as a key/comment pair.- Parameters:
line- what to look atisComment- whether this is a comment or not.- Throws:
IOException- when badness happens.
-
loadNameReplacement
public void loadNameReplacement(InputStream input) throws IOException
Read the name replacement data.- Parameters:
input- what to read- Throws:
IOException- if readline fails
-
load
public void load(InputStream input) throws IOException
Read the input stream into our structures.- Parameters:
input- what to read- Throws:
IOException- if readline fails
-
store
public void store(OutputStream output) throws IOException
Put the output to the supplied stream.- Parameters:
output- where to write- Throws:
IOException- is the write fails
-
replaceProperties
public void replaceProperties(Properties replacements)
Perform a mass replacement from the suppliedProperties.- Parameters:
replacements- what to replace.
-
replaceProperty
public boolean replaceProperty(String propName, String newPropValue)
Replace the supplied property or stuff it at the bottom of the list.- Parameters:
propName- the name of the property to replacenewPropValue- the value to replace- Returns:
- true if the property was replaced false if it was added
-
addComment
public void addComment(String what)
Append a comment to the list.- Parameters:
what- what to add
-
-