Class StringParameters
- java.lang.Object
-
- net.sf.okapi.common.BaseParameters
-
- net.sf.okapi.common.StringParameters
-
- All Implemented Interfaces:
Cloneable
,IParameters
- Direct Known Subclasses:
AbstractGroupParameters
,AutoXLIFFParameters
,ConditionalParameters
,DefaultParameters
,ExtractionVerificationStepParameters
,FilterWriterParameters
,GoogleAutoMLTranslationParameters
,GoogleMTv2Parameters
,KantanMTv21ConnectorParameters
,MergingParameters
,Options
,Options
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,Parameters
,ParametersSimpleWordCountStep
,SubtitleParameters
,TableFilterWriterParameters
,TerminologyParameters
,TTXJoinerParameters
,TTXSplitterParameters
,WhitespaceCorrectionStepParameters
,XLIFF2Options
,XliffJoinerParameters
,XliffSplitterParameters
,XliffWCSplitterParameters
,XLIFFWriterParameters
,XMLEncoder.Parameters
public class StringParameters extends BaseParameters
Parameters implementation based onParametersString
.Subclasses that wish to expose individual parameters via dedicated getters and setters should rely on the internal param buffer as much as possible. Any default values should be set in the implementation of
reset()
.
-
-
Field Summary
Fields Modifier and Type Field Description protected ParametersString
buffer
Buffer where the parameters are stored during conversion.-
Fields inherited from class net.sf.okapi.common.BaseParameters
path
-
-
Constructor Summary
Constructors Constructor Description StringParameters()
Creates a new StringParameters object with a null path and an empty buffer.StringParameters(String data)
Creates a new StringParameters object with a null path the specified initial parameter data
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
fromString(String data)
Reset this parameters object to its default values and then load additional parameters from the provided data.void
fromString(String data, boolean clearParameters)
Load additional parameters from the provided data.boolean
getBoolean(String name)
Gets the boolean value for the given parameter name.protected String
getGroup(String name)
int
getInteger(String name)
Gets the integer value for a given parameter name.String
getString(String name)
Gets the string value for a given parameter name.void
reset()
Reset this parameters object to its default values.void
setBoolean(String name, boolean value)
Sets the boolean value for a given parameter name.protected void
setGroup(String name, String value)
void
setInteger(String name, int value)
Sets the integer value for a given parameter name.void
setString(String name, String value)
Sets the string value for a given parameter name.String
toString()
Serialize this parameters object to a string.-
Methods inherited from class net.sf.okapi.common.BaseParameters
getParametersDescription, getPath, load, load, save, setPath
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.okapi.common.IParameters
copy
-
-
-
-
Field Detail
-
buffer
protected ParametersString buffer
Buffer where the parameters are stored during conversion.
-
-
Constructor Detail
-
StringParameters
public StringParameters()
Creates a new StringParameters object with a null path and an empty buffer.
-
StringParameters
public StringParameters(String data)
Creates a new StringParameters object with a null path the specified initial parameter data- Parameters:
data
- the string holding the parameters. SeeIParameters.fromString(java.lang.String)
.
-
-
Method Detail
-
reset
public void reset()
Reset this parameters object to its default values.Subclasses should override this method to set any initial values and instantiate any objects that require allocation. It is recommended that subclasses also call
super.reset()
in the override to ensure that the buffer is empty.
-
fromString
public void fromString(String data)
Reset this parameters object to its default values and then load additional parameters from the provided data.Subclasses should not normally need to override this method unless they are maintaining complex values (eg,
InlineCodeFinder
) that require extra initialization as part of their parameter state.- Parameters:
data
- the string holding the parameters. It must be formatted as the string generated by toString(). Line-breaks must be normalized to '\n'. It can also be null or empty, in such case the parameters are left with their current values. Use reset() to reset the parameters to their defaults.
-
fromString
public void fromString(String data, boolean clearParameters)
Load additional parameters from the provided data. If clearParameters is set, then it first resets this parameters object to its default values.Subclasses should not normally need to override this method unless they are maintaining complex values (eg,
InlineCodeFinder
) that require extra initialization as part of their parameter state.- Parameters:
data
- the string holding the parameters. SeeIParameters.fromString(java.lang.String)
.clearParameters
- if true, the internal parameters will be cleared before loading the data. If false, any existing parameters will be left intact unless they are overridden by the data.
-
toString
public String toString()
Serialize this parameters object to a string.Subclasses should not normally need to override this method unless they are maintaining complex values (eg,
InlineCodeFinder
) that require extra serialization as part of their parameter state.- Specified by:
toString
in interfaceIParameters
- Overrides:
toString
in classObject
- Returns:
- the string holding all the parameters.
-
getBoolean
public boolean getBoolean(String name)
Description copied from interface:IParameters
Gets the boolean value for the given parameter name.- Parameters:
name
- the name of the boolean parameter to retrieve.- Returns:
- the value of the given parameter, or false if it is not defined.
-
setBoolean
public void setBoolean(String name, boolean value)
Description copied from interface:IParameters
Sets the boolean value for a given parameter name.- Parameters:
name
- the name of the parameter to set.value
- the new value to set.
-
getString
public String getString(String name)
Description copied from interface:IParameters
Gets the string value for a given parameter name.- Parameters:
name
- the name of the string parameter to retrieve.- Returns:
- the value of the given parameter, or null if it is not defined.
-
setString
public void setString(String name, String value)
Description copied from interface:IParameters
Sets the string value for a given parameter name.- Parameters:
name
- the name of the parameter to set.value
- the new value to set.
-
getInteger
public int getInteger(String name)
Description copied from interface:IParameters
Gets the integer value for a given parameter name.- Parameters:
name
- the name of the integer parameter to retrieve.- Returns:
- the value of the given parameter, or 0 if it is not defined.
-
setInteger
public void setInteger(String name, int value)
Description copied from interface:IParameters
Sets the integer value for a given parameter name.- Parameters:
name
- the name of the parameter to set.value
- the new value to set.
-
-