Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
org.bukkit.configuration.file.FileConfiguration Class Referenceabstract
Inheritance diagram for org.bukkit.configuration.file.FileConfiguration:
org.bukkit.configuration.MemoryConfiguration org.bukkit.configuration.MemorySection org.bukkit.configuration.Configuration org.bukkit.configuration.ConfigurationSection org.bukkit.configuration.ConfigurationSection org.bukkit.configuration.file.YamlConfiguration

Public Member Functions

 FileConfiguration ()
 
 FileConfiguration (Configuration defaults)
 
void save (File file) throws IOException
 
void save (String file) throws IOException
 
abstract String saveToString ()
 
void load (File file) throws FileNotFoundException, IOException, InvalidConfigurationException
 
void load (InputStream stream) throws IOException, InvalidConfigurationException
 
void load (Reader reader) throws IOException, InvalidConfigurationException
 
void load (String file) throws FileNotFoundException, IOException, InvalidConfigurationException
 
abstract void loadFromString (String contents) throws InvalidConfigurationException
 
FileConfigurationOptions options ()
 
- Public Member Functions inherited from org.bukkit.configuration.MemoryConfiguration
 MemoryConfiguration ()
 
 MemoryConfiguration (Configuration defaults)
 
void addDefault (String path, Object value)
 
void addDefaults (Map< String, Object > defaults)
 
void addDefaults (Configuration defaults)
 
void setDefaults (Configuration defaults)
 
Configuration getDefaults ()
 
ConfigurationSection getParent ()
 
MemoryConfigurationOptions options ()
 
- Public Member Functions inherited from org.bukkit.configuration.MemorySection
Set< String > getKeys (boolean deep)
 
Map< String, Object > getValues (boolean deep)
 
boolean contains (String path)
 
boolean isSet (String path)
 
String getCurrentPath ()
 
String getName ()
 
Configuration getRoot ()
 
ConfigurationSection getParent ()
 
void addDefault (String path, Object value)
 
ConfigurationSection getDefaultSection ()
 
void set (String path, Object value)
 
Object get (String path)
 
Object get (String path, Object def)
 
ConfigurationSection createSection (String path)
 
ConfigurationSection createSection (String path, Map<?,?> map)
 
String getString (String path)
 
String getString (String path, String def)
 
boolean isString (String path)
 
int getInt (String path)
 
int getInt (String path, int def)
 
boolean isInt (String path)
 
boolean getBoolean (String path)
 
boolean getBoolean (String path, boolean def)
 
boolean isBoolean (String path)
 
double getDouble (String path)
 
double getDouble (String path, double def)
 
boolean isDouble (String path)
 
long getLong (String path)
 
long getLong (String path, long def)
 
boolean isLong (String path)
 
List<?> getList (String path)
 
List<?> getList (String path, List<?> def)
 
boolean isList (String path)
 
List< String > getStringList (String path)
 
List< Integer > getIntegerList (String path)
 
List< Boolean > getBooleanList (String path)
 
List< Double > getDoubleList (String path)
 
List< Float > getFloatList (String path)
 
List< Long > getLongList (String path)
 
List< Byte > getByteList (String path)
 
List< Character > getCharacterList (String path)
 
List< Short > getShortList (String path)
 
List< Map<?,?> > getMapList (String path)
 
Vector getVector (String path)
 
Vector getVector (String path, Vector def)
 
boolean isVector (String path)
 
OfflinePlayer getOfflinePlayer (String path)
 
OfflinePlayer getOfflinePlayer (String path, OfflinePlayer def)
 
boolean isOfflinePlayer (String path)
 
ItemStack getItemStack (String path)
 
ItemStack getItemStack (String path, ItemStack def)
 
boolean isItemStack (String path)
 
Color getColor (String path)
 
Color getColor (String path, Color def)
 
boolean isColor (String path)
 
ConfigurationSection getConfigurationSection (String path)
 
boolean isConfigurationSection (String path)
 
String toString ()
 

Static Public Attributes

static final boolean UTF8_OVERRIDE
 
static final boolean UTF_BIG
 
static final boolean SYSTEM_UTF
 

Protected Member Functions

abstract String buildHeader ()
 
- Protected Member Functions inherited from org.bukkit.configuration.MemorySection
 MemorySection ()
 
 MemorySection (ConfigurationSection parent, String path)
 
boolean isPrimitiveWrapper (Object input)
 
Object getDefault (String path)
 
void mapChildrenKeys (Set< String > output, ConfigurationSection section, boolean deep)
 
void mapChildrenValues (Map< String, Object > output, ConfigurationSection section, boolean deep)
 

Additional Inherited Members

- Static Public Member Functions inherited from org.bukkit.configuration.MemorySection
static String createPath (ConfigurationSection section, String key)
 
static String createPath (ConfigurationSection section, String key, ConfigurationSection relativeTo)
 
- Protected Attributes inherited from org.bukkit.configuration.MemoryConfiguration
Configuration defaults
 
MemoryConfigurationOptions options
 
- Protected Attributes inherited from org.bukkit.configuration.MemorySection
final Map< String, Object > map = new LinkedHashMap<String, Object>()
 

Detailed Description

This is a base class for all File based implementations of Configuration

Definition at line 30 of file FileConfiguration.java.

Constructor & Destructor Documentation

org.bukkit.configuration.file.FileConfiguration.FileConfiguration ( )

Creates an empty FileConfiguration with no default values.

Definition at line 69 of file FileConfiguration.java.

69  {
70  super();
71  }
org.bukkit.configuration.file.FileConfiguration.FileConfiguration ( Configuration  defaults)

Creates an empty FileConfiguration using the specified Configuration as a source for all default values.

Parameters
defaultsDefault value provider

Definition at line 79 of file FileConfiguration.java.

79  {
80  super(defaults);
81  }

Member Function Documentation

abstract String org.bukkit.configuration.file.FileConfiguration.buildHeader ( )
abstractprotected

Compiles the header for this FileConfiguration and returns the result.

This will use the header from options() -> FileConfigurationOptions#header(), respecting the rules of FileConfigurationOptions#copyHeader() if set.

Returns
Compiled header
void org.bukkit.configuration.file.FileConfiguration.load ( File  file) throws FileNotFoundException, IOException, InvalidConfigurationException

Loads this FileConfiguration from the specified location.

All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given file.

If the file cannot be loaded for any reason, an exception will be thrown.

This will attempt to use the Charset#defaultCharset() for files, unless UTF8_OVERRIDE but not UTF_BIG is specified.

Parameters
fileFile to load from.
Exceptions
FileNotFoundExceptionThrown when the given file cannot be opened.
IOExceptionThrown when the given file cannot be read.
InvalidConfigurationExceptionThrown when the given file is not a valid Configuration.
IllegalArgumentExceptionThrown when file is null.

Definition at line 164 of file FileConfiguration.java.

Referenced by org.bukkit.configuration.file.FileConfiguration.load(), and org.bukkit.configuration.file.YamlConfiguration.loadConfiguration().

164  {
165  Validate.notNull(file, "File cannot be null");
166 
167  final FileInputStream stream = new FileInputStream(file);
168 
169  load(new InputStreamReader(stream, UTF8_OVERRIDE && !UTF_BIG ? Charsets.UTF_8 : Charset.defaultCharset()));
170  }
void org.bukkit.configuration.file.FileConfiguration.load ( InputStream  stream) throws IOException, InvalidConfigurationException

Loads this FileConfiguration from the specified stream.

All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given stream.

This will attempt to use the Charset#defaultCharset(), unless UTF8_OVERRIDE or UTF_BIG is specified.

Parameters
streamStream to load from
Exceptions
IOExceptionThrown when the given file cannot be read.
InvalidConfigurationExceptionThrown when the given file is not a valid Configuration.
IllegalArgumentExceptionThrown when stream is null.
Deprecated:
This does not consider encoding
See also
load(Reader)

Definition at line 191 of file FileConfiguration.java.

References org.bukkit.configuration.file.FileConfiguration.load().

191  {
192  Validate.notNull(stream, "Stream cannot be null");
193 
194  load(new InputStreamReader(stream, UTF8_OVERRIDE ? Charsets.UTF_8 : Charset.defaultCharset()));
195  }
void org.bukkit.configuration.file.FileConfiguration.load ( Reader  reader) throws IOException, InvalidConfigurationException

Loads this FileConfiguration from the specified reader.

All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given stream.

Parameters
readerthe reader to load from
Exceptions
IOExceptionthrown when underlying reader throws an IOException
InvalidConfigurationExceptionthrown when the reader does not represent a valid Configuration
IllegalArgumentExceptionthrown when reader is null

Definition at line 210 of file FileConfiguration.java.

References org.bukkit.configuration.file.FileConfiguration.loadFromString().

210  {
211  BufferedReader input = reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader);
212 
213  StringBuilder builder = new StringBuilder();
214 
215  try {
216  String line;
217 
218  while ((line = input.readLine()) != null) {
219  builder.append(line);
220  builder.append('\n');
221  }
222  } finally {
223  input.close();
224  }
225 
226  loadFromString(builder.toString());
227  }
abstract void loadFromString(String contents)
void org.bukkit.configuration.file.FileConfiguration.load ( String  file) throws FileNotFoundException, IOException, InvalidConfigurationException

Loads this FileConfiguration from the specified location.

All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given file.

If the file cannot be loaded for any reason, an exception will be thrown.

Parameters
fileFile to load from.
Exceptions
FileNotFoundExceptionThrown when the given file cannot be opened.
IOExceptionThrown when the given file cannot be read.
InvalidConfigurationExceptionThrown when the given file is not a valid Configuration.
IllegalArgumentExceptionThrown when file is null.

Definition at line 247 of file FileConfiguration.java.

References org.bukkit.configuration.file.FileConfiguration.load().

247  {
248  Validate.notNull(file, "File cannot be null");
249 
250  load(new File(file));
251  }
abstract void org.bukkit.configuration.file.FileConfiguration.loadFromString ( String  contents) throws InvalidConfigurationException
abstract

Loads this FileConfiguration from the specified string, as opposed to from file.

All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given string.

If the string is invalid in any way, an exception will be thrown.

Parameters
contentsContents of a Configuration to load.
Exceptions
InvalidConfigurationExceptionThrown if the specified string is invalid.
IllegalArgumentExceptionThrown if contents is null.

Referenced by org.bukkit.configuration.file.FileConfiguration.load().

FileConfigurationOptions org.bukkit.configuration.file.FileConfiguration.options ( )

Gets the ConfigurationOptions for this Configuration.

All setters through this method are chainable.

Returns
Options for this configuration

Implements org.bukkit.configuration.Configuration.

Definition at line 283 of file FileConfiguration.java.

283  {
284  if (options == null) {
285  options = new FileConfigurationOptions(this);
286  }
287 
288  return (FileConfigurationOptions) options;
289  }
void org.bukkit.configuration.file.FileConfiguration.save ( File  file) throws IOException

Saves this FileConfiguration to the specified location.

If the file does not exist, it will be created. If already exists, it will be overwritten. If it cannot be overwritten or created, an exception will be thrown.

This method will save using the system default encoding, or possibly using UTF8.

Parameters
fileFile to save to.
Exceptions
IOExceptionThrown when the given file cannot be written to for any reason.
IllegalArgumentExceptionThrown when file is null.

Definition at line 98 of file FileConfiguration.java.

References org.bukkit.configuration.file.FileConfiguration.saveToString().

Referenced by org.bukkit.configuration.file.FileConfiguration.save(), and org.bukkit.plugin.java.JavaPlugin.saveConfig().

98  {
99  Validate.notNull(file, "File cannot be null");
100 
101  Files.createParentDirs(file);
102 
103  String data = saveToString();
104 
105  Writer writer = new OutputStreamWriter(new FileOutputStream(file), UTF8_OVERRIDE && !UTF_BIG ? Charsets.UTF_8 : Charset.defaultCharset());
106 
107  try {
108  writer.write(data);
109  } finally {
110  writer.close();
111  }
112  }
void org.bukkit.configuration.file.FileConfiguration.save ( String  file) throws IOException

Saves this FileConfiguration to the specified location.

If the file does not exist, it will be created. If already exists, it will be overwritten. If it cannot be overwritten or created, an exception will be thrown.

This method will save using the system default encoding, or possibly using UTF8.

Parameters
fileFile to save to.
Exceptions
IOExceptionThrown when the given file cannot be written to for any reason.
IllegalArgumentExceptionThrown when file is null.

Definition at line 129 of file FileConfiguration.java.

References org.bukkit.configuration.file.FileConfiguration.save().

129  {
130  Validate.notNull(file, "File cannot be null");
131 
132  save(new File(file));
133  }
abstract String org.bukkit.configuration.file.FileConfiguration.saveToString ( )
abstract

Saves this FileConfiguration to a string, and returns it.

Returns
String containing this configuration.

Referenced by org.bukkit.configuration.file.FileConfiguration.save().

Member Data Documentation

final boolean org.bukkit.configuration.file.FileConfiguration.SYSTEM_UTF
static

This value specifies if the system supports unicode.

Deprecated:
temporary compatibility measure

Definition at line 54 of file FileConfiguration.java.

final boolean org.bukkit.configuration.file.FileConfiguration.UTF8_OVERRIDE
static

This value specified that the system default encoding should be completely ignored, as it cannot handle the ASCII character set, or it is a strict-subset of UTF8 already (plain ASCII).

Deprecated:
temporary compatibility measure

Definition at line 39 of file FileConfiguration.java.

Referenced by org.bukkit.plugin.java.JavaPlugin.getTextResource(), and org.bukkit.plugin.java.JavaPlugin.reloadConfig().

final boolean org.bukkit.configuration.file.FileConfiguration.UTF_BIG
static

This value specifies if the system default encoding is unicode, but cannot parse standard ASCII.

Deprecated:
temporary compatibility measure

Definition at line 47 of file FileConfiguration.java.


The documentation for this class was generated from the following file: