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 class`
`PropertiesWithComments.CommentedProperty`
A POJO which looks like a property.

## Field Summary

Fields
Modifier and Type
Field
Description
`private List<Object>`
`contents`
The contents.
`private boolean`
`loadedData`
Have we loaded data?.
`private final Properties`
`nameReplacement`
Name Replacement info.
`private Map<String,PropertiesWithComments.CommentedProperty>`
`properties`
The properties bit.
`private final Set<String>`
`unreplacableNames`
BlackListed property names.

## Constructor Summary

Constructors
Constructor
Description
`PropertiesWithComments()`
Legacy Constructor.
`PropertiesWithComments(Set<String> unreplacable)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`addComment(String what)`
Append a comment to the list.
`private void`
`addCommentedProperty(String line, boolean isComment)`
Add a property, either as a key/value pair or as a key/comment pair.
`void`
`load(InputStream input)`
Read the input stream into our structures.
`void`
`loadNameReplacement(InputStream input)`
Read the name replacement data.
`void`
`replaceProperties(Properties replacements)`
Perform a mass replacement from the supplied `Properties`.
`boolean`
`replaceProperty(String propName, String newPropValue)`
Replace the supplied property or stuff it at the bottom of the list.
`void`
`store(OutputStream output)`
Put the output to the supplied stream.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### contents

private List<Object> contents
The contents. Each `Object` is either a string (a non-property line) or a `PropertiesWithComments.CommentedProperty` (an optionally commented property definition).

### properties

private Map<String,PropertiesWithComments.CommentedProperty> properties
The properties bit.

### nameReplacement

@Nonnull private final Properties nameReplacement
Name Replacement info.

### unreplacableNames

@Nonnull private final Set<String> unreplacableNames
BlackListed property names.

### loadedData

private boolean loadedData
Have we loaded data?. We cannot load the replacement names after the file load.

## Constructor Details

### PropertiesWithComments

public PropertiesWithComments()
Legacy Constructor.

### PropertiesWithComments

public PropertiesWithComments(@Nonnull Set<String> unreplacable)
Constructor.

Parameters:
  `unreplacable` - names to warn on.

## Method Details

### 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 at
  `isComment` - 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 supplied `Properties`.

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 replace
  `newPropValue` - 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