public class FileNameTranslator1 extends java.lang.Object implements FileNameTranslator
This translator implementation returns a substring extracted from a given
value beginning at the nth character followng a searched character, where the
search character and nth character are defined by the translator's arguments
(see setArgs
).
Modifier and Type | Field and Description |
---|---|
protected int |
ivSkipChar
The number of characters to skip in the value to translate after finding
the search character.
|
protected java.lang.String |
ivSrchChar
The character to search for in the value to translate.
|
private static long |
serialVersionUID
The class' serialization version id.
|
TYPE_DESCR, TYPE_IMAGE
Constructor and Description |
---|
FileNameTranslator1() |
Modifier and Type | Method and Description |
---|---|
boolean |
setArgs(java.lang.String args)
Sets arguments used by the configured translator.
|
java.lang.String |
translate(java.lang.String value,
int type,
int size)
Performs translation for the given value (which would typically be a
product code), file type (TYPE_IMAGE, TYPE_DESCR) and file size
(Product.SIZE_SMALL, Product.SIZE_LARGE) and returns the translated
result.
|
private static final long serialVersionUID
protected java.lang.String ivSrchChar
protected int ivSkipChar
public boolean setArgs(java.lang.String args)
DBUFactory.getTranslator
method to obtain an instance of the translator,
the arguments are automatically set using the "dbutl.FileNameTranslator.args"
property value.
This translator implementation requires a single string of 2 arguments separated by a comma.
setArgs
in interface FileNameTranslator
args
- (String) The translator's arguments.true
if arguments were succesfully set,
otherwise false
.public java.lang.String translate(java.lang.String value, int type, int size)
See the class javadocs for a description of the translation performed by this translator implementation.
translate
in interface FileNameTranslator
value
- (String) The value to be translated.type
- (int) The type of file to be translated. Must be one
of the types defined by this class (TYPE_IMAGE
or
TYPE_DESCR
).size
- (int) The size of file to be translated. Must be one
of the sizes defined by the Product
class (SIZE_SMALL
or SIZE_LARGE
).