public class BasicCommandFactory extends Object implements NamedCommandFactory
CommandFactory
,
DefaultCommandFactory
Modifier and Type | Field and Description |
---|---|
protected Properties |
commandLookupProperties
Set of provided command properties.
|
protected static List<String> |
EMPTY_STRING_LIST |
protected String |
factoryName
Name of this command factory, usually its properties file name.
|
Modifier | Constructor and Description |
---|---|
protected |
BasicCommandFactory()
Constructor
|
protected |
BasicCommandFactory(InputStream propertyInputStream,
String factoryName)
Constructor, reads a property list (key and element pairs) from the given input stream and
fills up the contained
commandLookupProperties . |
protected |
BasicCommandFactory(String propertiesFileName)
Constructor, invokes the loading of the property file name resource and fills up the contained
commandLookupProperties . |
Modifier and Type | Method and Description |
---|---|
void |
clearLookupProperties()
Clears the lookup properties.
|
protected Command |
createCommand(String key) |
Command |
getCommand(String key)
Default constructor using the settings of the commands.properties file.
|
protected String |
getCommandClassname(String key)
Returns the command class name for given key, provided by embedded
commandLookupProperties , or an empty string if no command entry was found. |
String |
getFactoryName()
Returns the name of this factory, usually its properties file name.
|
String |
getLookupProperty(String key)
Allows an application to request lookup properties programmatically.
|
protected void |
loadProperties(InputStream is)
Reads a property list (key and element pairs) from the input stream and fills the embedded
commandLookupProperties . |
protected void |
loadProperties(String propertiesFileName)
Reads a property list (key and element pairs) from the input file name and fills the embedded
commandLookupProperties . |
void |
putLookupProperty(String key,
String value)
Deprecated.
use
setLookupProperty(String, String) instead |
void |
removeLookupProperty(String key)
Removes the value for given key.
|
protected void |
setFactoryName(String factoryName)
Changes the name of this factory.
|
void |
setLookupProperty(String key,
String value)
Allows an application to overwrite or set lookup properties programmatically.
|
protected Properties commandLookupProperties
protected String factoryName
protected BasicCommandFactory(String propertiesFileName) throws Exception
commandLookupProperties
.propertiesFileName
- for which should be factory createdException
Properties
protected BasicCommandFactory()
protected BasicCommandFactory(InputStream propertyInputStream, String factoryName) throws Exception
commandLookupProperties
.propertyInputStream
- the inputstream to read the command propertiesfactoryName
- name of this factoryException
Properties
public Command getCommand(String key)
CommandFactory
Algorithm of the command creating:
first:
lookup, if the command is already in the cache
second:
create command, if not already in the cache otherwise next point.
third:
return the created command.
getCommand
in interface CommandFactory
key
- of the command (ID)CommandFactory.getCommand(String)
protected String getCommandClassname(String key)
commandLookupProperties
, or an empty string if no command entry was found.key
- protected void loadProperties(String propertiesFileName) throws IOException
commandLookupProperties
.propertiesFileName
- from which should be the informations readIOException
protected void loadProperties(InputStream is) throws IOException
commandLookupProperties
.IOException
public String getFactoryName()
getFactoryName
in interface NamedCommandFactory
protected void setFactoryName(String factoryName)
factoryName
- the new factory name@Deprecated public void putLookupProperty(String key, String value)
setLookupProperty(String, String)
insteadkey
- value
- The value of the given key, null
if the key is not mapped to any
value.NullPointerException
- if the key or value is null
.public void setLookupProperty(String key, String value)
key
- value
- The value of the given key, null
if the key is not mapped to any
value.public void removeLookupProperty(String key)
key
- public void clearLookupProperties()
public String getLookupProperty(String key)
key
- a key to look upnull
if the key is not mapped to any
value.NullPointerException
- if the key is null.Copyright © 2024 levigo holding gmbh. All rights reserved.