public class DefaultProfile extends Profile
Modifier and Type | Field and Description |
---|---|
static java.lang.String[] |
ALL_ENABLED
A value for the
enabledIds argument of some constructors that
indicates all ids should be enabled. |
static java.lang.String[] |
NONE_ENABLED
A value for the
enabledIds argument of some constructors that
indicates all ids should be disabled. |
Constructor and Description |
---|
DefaultProfile(ExtensionBeanFactory factory,
ProfileDefinition definition,
java.lang.String name,
java.net.URL url)
Creates a new unsealed factory profile from a profile file.
|
DefaultProfile(ExtensionBeanFactory factory,
java.lang.String name,
boolean seal,
java.lang.String... enabledIds)
Creates a new user profile from a list of ids to enable using the default
extension bean definitions.
|
DefaultProfile(ExtensionBeanFactory factory,
java.lang.String name,
java.lang.String... enabledIds)
Creates a new unsealed user profile from a list of ids to enable using the
default extension bean definitions.
|
DefaultProfile(ExtensionBeanFactory factory,
java.net.URL url,
boolean seal)
Creates a new user or factory profile from a profile file.
|
DefaultProfile(Profile profile,
ProfileDefinition definition) |
DefaultProfile(Profile profile,
java.net.URL url) |
DefaultProfile(java.lang.String name,
java.lang.String... ids)
Creates a new user from a list of ids to enable using the default extension
bean definitions.
|
DefaultProfile(java.lang.String name,
java.net.URL url)
Creates a new user from a profile file using the default extension bean
definitions.
|
DefaultProfile(java.net.URL url)
Creates a new user or factory profile from a profile file using the default
extension bean definitions.
|
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(javax.swing.event.ChangeListener listener)
Adds a change listener to be notified when changes are applied to this
profile.
|
void |
applyChanges(ProfileTransaction transaction)
Apply the changes in a transaction to this profile.
|
ExtensionBean |
createBean(BeanDefinition definition,
boolean force,
java.util.Map<java.lang.String,ExtensionBean> context)
Creates an instance of a bean in this profile.
|
java.util.Map<java.lang.String,ExtensionBean> |
createBeans(boolean force)
Creates instances of all beans in this profile.
|
ProfileTransaction |
createTransaction()
Creates a transaction for this profile.
|
boolean |
equals(java.lang.Object object) |
ValueHandle |
getChangedValue(java.lang.String id,
java.lang.String propertyName)
Gets the value of a property of a bean of this profile changed from its
default value, null if not changed.
|
MultiMap<java.lang.String,ValueHandle> |
getChangedValues()
Gets the properties of beans of this profile changed from their
default values.
|
java.util.Collection<ValueHandle> |
getChangedValues(java.lang.String id)
Gets the properties of a bean of this profile changed from their
default values, or null if none.
|
java.lang.Object |
getDefaultValue(BeanDefinition definition,
java.lang.String propertyName)
Gets the default value of a property of a bean of this profile.
|
ProfileDefinition |
getDefinition()
Gets the definition of this profile, or null if not a predefined profile.
|
BeanDefinition |
getDefinition(java.lang.String id)
Gets the definition of a specified bean in this profile, or null if none.
|
java.util.Collection<BeanDefinition> |
getDefinitions()
Gets the definitions of all beans in this profile.
|
ExtensionBeanFactory |
getFactory()
Gets the extension bean factory of this profile.
|
java.lang.String |
getId()
Gets the id of this profile, or null if not a predefined profile.
|
java.lang.String |
getName()
Gets the name of this profile.
|
java.net.URL |
getURL()
Gets the URL from which to load properties of this profile, or null if
this profile is not associated with a file.
|
int |
hashCode() |
boolean |
isEnabled(java.lang.String id)
Gets whether a bean in this profile is enabled.
|
boolean |
isSealed()
Gets whether this profile is sealed.
|
static java.lang.String |
readName(java.net.URL url)
Reads the name from a profile file without actually constructing a profile.
|
void |
removeChangeListener(javax.swing.event.ChangeListener listener)
Adds a change listener to be notified when changes are applied to this
profile.
|
void |
save(java.net.URL url)
Saves this profile.
|
java.lang.String |
toString() |
public static final java.lang.String[] NONE_ENABLED
enabledIds
argument of some constructors that
indicates all ids should be disabled.public static final java.lang.String[] ALL_ENABLED
enabledIds
argument of some constructors that
indicates all ids should be enabled.public DefaultProfile(java.net.URL url) throws java.io.IOException
url
- The URL
of the profile file.java.io.IOException
- if the profile file cannot be processed.public DefaultProfile(ExtensionBeanFactory factory, java.net.URL url, boolean seal) throws java.io.IOException
factory
- The factory defining the beans for this profile.url
- The URL
of the profile file.seal
- Whether to seal the profile if it was not saved sealed.java.io.IOException
- if the profile file cannot be processed.public DefaultProfile(java.lang.String name, java.net.URL url) throws java.io.IOException
name
- The name of the profile.url
- The url of a profile file.java.io.IOException
- if loading from the profile file fails.public DefaultProfile(ExtensionBeanFactory factory, ProfileDefinition definition, java.lang.String name, java.net.URL url) throws java.io.IOException
factory
- The factory defining the beans for this profile.definition
- The definition of this profile.name
- The name of the profile.url
- The url of a profile file.java.io.IOException
- if loading from the profile file fails.public DefaultProfile(java.lang.String name, java.lang.String... ids)
name
- The name of the profile.ids
- The ids to enable, or ALL_ENABLED
or NONE_ENABLED
to enable all or none.public DefaultProfile(ExtensionBeanFactory factory, java.lang.String name, java.lang.String... enabledIds)
factory
- The factory defining the beans for this profile.name
- The name of the profile.enabledIds
- The ids to enable, or ALL_ENABLED
or NONE_ENABLED
to enable all or none.public DefaultProfile(ExtensionBeanFactory factory, java.lang.String name, boolean seal, java.lang.String... enabledIds)
factory
- The factory defining the beans for this profile.name
- The name of the profile.seal
- Whether to seal the profile.enabledIds
- The ids to enable, or ALL_ENABLED
or NONE_ENABLED
enable or disable all defined beans.public DefaultProfile(Profile profile, java.net.URL url)
public DefaultProfile(Profile profile, ProfileDefinition definition)
public static java.lang.String readName(java.net.URL url) throws java.io.IOException
url
- The URL of the profile file.java.io.IOException
- if the name cannot be read.public ProfileDefinition getDefinition()
Profile
getDefinition
in class Profile
public ExtensionBeanFactory getFactory()
Profile
getFactory
in class Profile
public java.lang.String getId()
Profile
public java.lang.String getName()
Profile
public java.net.URL getURL()
Profile
public java.util.Collection<BeanDefinition> getDefinitions()
Profile
getDefinitions
in class Profile
public BeanDefinition getDefinition(java.lang.String id)
Profile
getDefinition
in class Profile
id
- the id of the bean.public boolean isSealed()
Profile
public java.util.Map<java.lang.String,ExtensionBean> createBeans(boolean force)
Profile
When force is true, loading classes is first tried with the Audit class loader before an unloaded extension is loaded.
createBeans
in class Profile
force
- Whether to load the extension defining this bean if needed.public ExtensionBean createBean(BeanDefinition definition, boolean force, java.util.Map<java.lang.String,ExtensionBean> context)
Profile
When force is true, loading classes is first tried with the Audit class loader before an unloaded extension is loaded.
The created bean is added to the context map, referenced beans are taken from the context map if present, otherwise they are created and added to the context map.
createBean
in class Profile
definition
- The definition of the bean to load.force
- Whether to load the extension defining this bean if needed.context
- Context map for the created bean.public java.lang.Object getDefaultValue(BeanDefinition definition, java.lang.String propertyName) throws java.beans.IntrospectionException, java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
Profile
getDefaultValue
in class Profile
definition
- The definition of the bean.propertyName
- The name of the property.java.beans.IntrospectionException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
public boolean isEnabled(java.lang.String id)
Profile
public MultiMap<java.lang.String,ValueHandle> getChangedValues()
Profile
getChangedValues
in class Profile
public java.util.Collection<ValueHandle> getChangedValues(java.lang.String id)
Profile
getChangedValues
in class Profile
public ValueHandle getChangedValue(java.lang.String id, java.lang.String propertyName)
Profile
getChangedValue
in class Profile
id
- the id of the bean.propertyName
- the name of the property.public ProfileTransaction createTransaction()
Profile
createTransaction
in class Profile
public void addChangeListener(javax.swing.event.ChangeListener listener)
Profile
addChangeListener
in class Profile
public void removeChangeListener(javax.swing.event.ChangeListener listener)
Profile
removeChangeListener
in class Profile
public void applyChanges(ProfileTransaction transaction)
Profile
applyChanges
in class Profile
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object