|
Jalopy 1.0b10 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.hunsicker.jalopy.storage.Convention
Represents a code convention: the settings that describe the desired coding style for Java source files.
To ensure type-safety, valid key access, two accompanying classes are provided:
Convention
settings =Convention
.getInstance(); int numThreads = settings.getInt(ConventionKeys
.THREAD_COUNT,ConventionDefaults
.THREAD_COUNT));
ConventionKeys
,
ConventionDefaults
Inner Class Summary | |
static class |
Convention.Key
A key for storing a value in a code convention. |
Field Summary | |
static String |
EXTENSION_DAT
The file extension for Jalopy local binary code convention files (".dat"). |
static String |
EXTENSION_JAL
The file extension for Jalopy binary code convention files (".jal"). |
static String |
EXTENSION_XML
The file extension for Jalopy XML code convention files (".xml"). |
Method Summary | |
static void |
addProject(Project project)
Adds a new project. |
void |
exportSettings(File file)
Exports the code convention to the given file. |
void |
exportSettings(OutputStream out,
String extension)
Emits the code convention in a format indicated by the given extension. |
void |
flush()
Flushes the code convention to the persistent store. |
String |
get(Convention.Key key,
String def)
Returns the value associated with the given key. |
static File |
getBackupDirectory()
Returns the current project's backup directory path. |
boolean |
getBoolean(Convention.Key key,
boolean def)
Returns the boolean value associated with the given key. |
static Project |
getDefaultProject()
Returns the default project. |
static File |
getHistoryFile()
Returns the history backing store file. |
static Convention |
getInstance()
Returns the sole instance of this object. |
int |
getInt(Convention.Key key,
int def)
Returns the int value represented by the string associated with the specified key in this preference node. |
Locale |
getLocale()
Returns the preferred locale. |
static File |
getProjectSettingsDirectory()
Returns the current project settings directory. |
static File |
getRepositoryDirectory()
Returns the current project's class repository directory. |
static File |
getSettingsDirectory()
Returns the base settings directory. |
static File |
getSettingsFile()
Returns the local code convention file. |
static void |
importSettings(File file)
Imports the code convention from the given file. |
static void |
importSettings(InputStream in,
String extension)
Imports the code convention from the specified input stream. |
static void |
importSettings(URL url)
Imports the code convention from the specified url. |
void |
put(Convention.Key key,
String value)
Implements the put method as per the specification in put(Convention.Key,String) . |
void |
putBoolean(Convention.Key key,
boolean value)
Implements the putBoolean method as per the specification in putBoolean(Convention.Key,boolean) . |
void |
putInt(Convention.Key key,
int value)
Implements the putInt method as per the specification in putInt(Convention.Key,int) . |
static void |
removeProject(Project project)
Removes the given project. |
void |
revert()
Reverts the code convention to the state of the last snapshot. |
static boolean |
setProject(Project project)
Sets the currently active project. |
void |
snapshot()
Creates an internal snapshot of the current code convention. |
String |
toString()
Returns a string representation of this object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String EXTENSION_JAL
public static final String EXTENSION_XML
public static final String EXTENSION_DAT
Method Detail |
public static File getBackupDirectory()
public static Project getDefaultProject()
public static File getHistoryFile()
public static Convention getInstance()
public Locale getLocale()
public static boolean setProject(Project project)
project
- the new active project.true
if setting the project was successful.public static File getProjectSettingsDirectory()
public static File getRepositoryDirectory()
public static File getSettingsDirectory()
public static File getSettingsFile()
public static void addProject(Project project) throws IOException
project
- the project information.IOException
- if an I/O error occured.public static void importSettings(InputStream in, String extension) throws IOException
in
- the input stream from which to read the code convention.extension
- file extension indicating the format of the saved code
convention.IOException
- if an I/O error occured.IllegalArgumentException
- if an invalid extension was specified.public static void importSettings(URL url) throws IOException
url
- url to import the code convention from.IOException
- an I/O error occured.ChainingRuntimeException
- DOCUMENT ME!public static void importSettings(File file) throws IOException
file
- code convention file.IOException
- if an I/O error occured.FileNotFoundException
- DOCUMENT ME!IllegalArgumentException
- DOCUMENT ME!public static void removeProject(Project project) throws IOException
project
- a project.IOException
- if an I/O error occured.public boolean getBoolean(Convention.Key key, boolean def)
This implementation invokes get(key,
null)
. If the return value is non-null, it is compared with "true"
using String.equalsIgnoreCase(String)
. If the comparison returns
true, this invocation returns true. Otherwise, the original
return value is compared with "false", again using String.equalsIgnoreCase(String)
. If the comparison returns true, this
invocation returns false. Otherwise, this invocation returns
def.
key
- key whose associated value is to be returned as a boolean.def
- the value to be returned in the event that this preference node has no
value associated with key or the associated value cannot be
interpreted as a boolean.public int getInt(Convention.Key key, int def)
Integer.parseInt(String)
. Returns the specified default if there is no value
associated with the key, the backing store is inaccessible, or if Integer.parseInt(String)
would throw a NumberFormatException
if the
associated value were passed. This method is intended for use in conjunction with
putInt(de.hunsicker.jalopy.storage.Convention.Key, int)
.key
- key whose associated value is to be returned as an int.def
- the value to be returned in the event that this preference node has no
value associated with key or the associated value cannot be
interpreted as an int, or the backing store is inaccessible.putInt(Convention.Key,int)
,
get(Convention.Key,String)
public void exportSettings(File file) throws IOException
file
- file to export the code convention to.IOException
- if writing to the specified output stream failed.public void exportSettings(OutputStream out, String extension) throws IOException
.jal
format).out
- the output stream on which to emit the code convention.extension
- output format to use. Either EXTENSION_JAL
or EXTENSION_XML
.IOException
- if an I/O error occured.IllegalArgumentException
- if extension is no valid file extension.public void flush() throws IOException
IOException
- if an I/O error occured.public String get(Convention.Key key, String def)
This implementation first checks to see if key is null throwing a NullPointerException if this is the case.
key
- key whose associated value is to be returned.def
- the value to be returned in the event that this preference node has no
value associated with key.NullPointerException
- if key is null. (A null default
is permitted.)public void put(Convention.Key key, String value)
put(Convention.Key,String)
.key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.NullPointerException
- if key or value is null.public void putBoolean(Convention.Key key, boolean value)
putBoolean(Convention.Key,boolean)
.
This implementation translates value to a string with String.valueOf(boolean)
and invokes put(Convention.Key,String)
on the
result.
key
- key with which the string form of value is to be associated.value
- value whose string form is to be associated with key.public void putInt(Convention.Key key, int value)
putInt(Convention.Key,int)
.
This implementation translates value to a string with Integer.toString(int)
and invokes put(Convention.Key,String)
on the
result.
key
- key with which the string form of value is to be associated.value
- value whose string form is to be associated with key.public void revert()
snapshot()
public void snapshot()
revert()
at any time to revert the code convention to the state of the
last snapshot.revert()
public String toString()
toString
in class Object
|
Jalopy 1.0b10 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |