public class FileSystemTiledReader extends TiledReader
A FileSystemTiledReader is a type of TiledReader that locates and identifies resources using standard paths through the local file system, and caches resources in a HashMap with canonical path strings as keys. This is the best type of TiledReader to use if you're not doing anything fancy with file storage and not trying to integrate TiledReader with an existing asset management system.
LOGGER, TILED_VERSION, TMX_VERSION, VERSION
Constructor and Description |
---|
FileSystemTiledReader()
Constructs a new FileSystemTiledReader.
|
Modifier and Type | Method and Description |
---|---|
protected void |
clearCachedResources()
Clears the cache, causing it to no longer identify any resource by any
path.
|
TiledResource |
getCachedResource(String path)
Returns the resource in the cache identified by the specified path, which
must be a canonical path by the standards of getCanonicalPath().
|
String |
getCanonicalPath(String path)
Returns a version of the specified path string that is both absolute and
unique.
|
InputStream |
getInputStream(String path)
Returns an InputStream that reads the file data at the location of the
specified path, which must be a canonical path by the standards of
getCanonicalPath().
|
String |
joinPaths(String basePath,
String relativePath)
Returns a path string that points to the same location as the specified
relative path does when followed from the location of the specified base
path.
|
protected void |
removeCachedResource(String path)
Sets the cache to no longer identify any resource by the specified path,
which must be a canonical path by the standards of getCanonicalPath().
|
protected void |
setCachedResource(String path,
TiledResource resource)
Sets the cache to identify the specified resource by the specified path,
which must be a canonical path by the standards of getCanonicalPath().
|
clearResources, getMap, getObjectTypes, getTemplate, getTileset, readObjectTypes, removeResource, setObjectTypes
public FileSystemTiledReader()
public final String getCanonicalPath(String path)
TiledReader
java.io.File.getCanonicalPath()
.getCanonicalPath
in class TiledReader
path
- The path to find the canonical version ofpublic final String joinPaths(String basePath, String relativePath)
TiledReader
java.nio.file.Path.resolve()
.joinPaths
in class TiledReader
basePath
- The base pathrelativePath
- The relative pathpublic final InputStream getInputStream(String path)
TiledReader
getInputStream
in class TiledReader
path
- The canonical path to the file datapublic final TiledResource getCachedResource(String path)
TiledReader
getCachedResource
in class TiledReader
path
- The canonical path to the file from which the resource was
readprotected final void setCachedResource(String path, TiledResource resource)
TiledReader
setCachedResource
in class TiledReader
path
- The canonical path by which to identify the resourceresource
- The resource to be identified by the pathprotected final void removeCachedResource(String path)
TiledReader
removeCachedResource
in class TiledReader
path
- The canonical path that identifies the resource to remove
from the cacheprotected final void clearCachedResources()
TiledReader
clearCachedResources
in class TiledReader
Copyright © 2020. All rights reserved.