Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
FileConfigurationOptions.java
1 package org.bukkit.configuration.file;
2 
3 import org.bukkit.configuration.*;
4 
5 /**
6  * Various settings for controlling the input and output of a {@link
7  * FileConfiguration}
8  */
10  private String header = null;
11  private boolean copyHeader = true;
12 
13  protected FileConfigurationOptions(MemoryConfiguration configuration) {
14  super(configuration);
15  }
16 
17  @Override
18  public FileConfiguration configuration() {
19  return (FileConfiguration) super.configuration();
20  }
21 
22  @Override
23  public FileConfigurationOptions copyDefaults(boolean value) {
24  super.copyDefaults(value);
25  return this;
26  }
27 
28  @Override
29  public FileConfigurationOptions pathSeparator(char value) {
30  super.pathSeparator(value);
31  return this;
32  }
33 
34  /**
35  * Gets the header that will be applied to the top of the saved output.
36  * <p>
37  * This header will be commented out and applied directly at the top of
38  * the generated output of the {@link FileConfiguration}. It is not
39  * required to include a newline at the end of the header as it will
40  * automatically be applied, but you may include one if you wish for extra
41  * spacing.
42  * <p>
43  * Null is a valid value which will indicate that no header is to be
44  * applied. The default value is null.
45  *
46  * @return Header
47  */
48  public String header() {
49  return header;
50  }
51 
52  /**
53  * Sets the header that will be applied to the top of the saved output.
54  * <p>
55  * This header will be commented out and applied directly at the top of
56  * the generated output of the {@link FileConfiguration}. It is not
57  * required to include a newline at the end of the header as it will
58  * automatically be applied, but you may include one if you wish for extra
59  * spacing.
60  * <p>
61  * Null is a valid value which will indicate that no header is to be
62  * applied.
63  *
64  * @param value New header
65  * @return This object, for chaining
66  */
67  public FileConfigurationOptions header(String value) {
68  this.header = value;
69  return this;
70  }
71 
72  /**
73  * Gets whether or not the header should be copied from a default source.
74  * <p>
75  * If this is true, if a default {@link FileConfiguration} is passed to
76  * {@link
77  * FileConfiguration#setDefaults(org.bukkit.configuration.Configuration)}
78  * then upon saving it will use the header from that config, instead of
79  * the one provided here.
80  * <p>
81  * If no default is set on the configuration, or the default is not of
82  * type FileConfiguration, or that config has no header ({@link #header()}
83  * returns null) then the header specified in this configuration will be
84  * used.
85  * <p>
86  * Defaults to true.
87  *
88  * @return Whether or not to copy the header
89  */
90  public boolean copyHeader() {
91  return copyHeader;
92  }
93 
94  /**
95  * Sets whether or not the header should be copied from a default source.
96  * <p>
97  * If this is true, if a default {@link FileConfiguration} is passed to
98  * {@link
99  * FileConfiguration#setDefaults(org.bukkit.configuration.Configuration)}
100  * then upon saving it will use the header from that config, instead of
101  * the one provided here.
102  * <p>
103  * If no default is set on the configuration, or the default is not of
104  * type FileConfiguration, or that config has no header ({@link #header()}
105  * returns null) then the header specified in this configuration will be
106  * used.
107  * <p>
108  * Defaults to true.
109  *
110  * @param value Whether or not to copy the header
111  * @return This object, for chaining
112  */
113  public FileConfigurationOptions copyHeader(boolean value) {
114  copyHeader = value;
115 
116  return this;
117  }
118 }