public class DefaultFilenamePolicy extends Object implements IFilenamePolicy
IFilenamePolicy
that
creates filenames from objects or aggregation objects according to the
following rules:
textgrid:
scheme,FileExtensionMap.getFirstExtension(String)
from the object's
format field. The extension is only included when the
asParent parameter is false
./
appended.
Modifier and Type | Field and Description |
---|---|
static DefaultFilenamePolicy |
INSTANCE
Since this is a stateless implementation, clients can use the default instance
|
protected static String |
TRANSFORM_RULES
These are the ICU transformation rules used for
translate(String) . |
Constructor and Description |
---|
DefaultFilenamePolicy() |
Modifier and Type | Method and Description |
---|---|
com.google.common.base.Optional<URI> |
getBase(IAggregationEntry entry)
Tries to generate a base URI for the given aggregation entry.
|
URI |
getFilename(IAggregationEntry entry)
Generates a file name for the aggregation entry described by the given
metadata.
|
URI |
getFilename(IAggregationEntry entry,
boolean asParent)
Generates a file name for the aggregation entry described by the given
metadata.
|
String |
getFilename(info.textgrid.namespaces.metadata.core._2010.ObjectType object,
boolean asParent)
Generates a file name candidate for the object described by the given
metadata.
|
protected static com.ibm.icu.text.Transliterator |
getTransliterator()
Returns (and creates on demand) an ICU transliterator as used in
translate(String) |
String |
translate(String title)
Creates a valid file name part for the given string.
|
public static final DefaultFilenamePolicy INSTANCE
protected static String TRANSFORM_RULES
translate(String)
.protected static com.ibm.icu.text.Transliterator getTransliterator()
translate(String)
public String translate(String title)
IFilenamePolicy
translate
in interface IFilenamePolicy
title
- The string that should be translatedpublic String getFilename(info.textgrid.namespaces.metadata.core._2010.ObjectType object, boolean asParent)
IFilenamePolicy
getFilename
in interface IFilenamePolicy
object
- The object with the metadata for which to generate a filenameasParent
- If true, the generated file name should be the parent for a
different filename. Implementors might, e.g., want to leave
out an extension.public URI getFilename(IAggregationEntry entry)
IFilenamePolicy
getFilename
in interface IFilenamePolicy
IFilenamePolicy.getFilename(ObjectType, boolean)
public URI getFilename(IAggregationEntry entry, boolean asParent)
IFilenamePolicy
getFilename
in interface IFilenamePolicy
IFilenamePolicy.getFilename(ObjectType, boolean)
public com.google.common.base.Optional<URI> getBase(IAggregationEntry entry)
IFilenamePolicy
getBase
in interface IFilenamePolicy
Copyright © 2017 TextGrid. All rights reserved.