JavaDoc for properties classes.

This commit is contained in:
Michael Jumper
2011-05-14 23:40:27 -07:00
parent 3fe4aab695
commit 65b0f08fd9
5 changed files with 63 additions and 1 deletions

View File

@@ -22,6 +22,11 @@ package net.sourceforge.guacamole.properties;
import java.io.File; import java.io.File;
import net.sourceforge.guacamole.GuacamoleException; import net.sourceforge.guacamole.GuacamoleException;
/**
* A GuacamoleProperty whose value is a filename.
*
* @author Michael Jumper
*/
public abstract class FileGuacamoleProperty implements GuacamoleProperty<File> { public abstract class FileGuacamoleProperty implements GuacamoleProperty<File> {
@Override @Override

View File

@@ -24,10 +24,20 @@ import java.io.InputStream;
import java.util.Properties; import java.util.Properties;
import net.sourceforge.guacamole.GuacamoleException; import net.sourceforge.guacamole.GuacamoleException;
/**
* Simple utility class for reading properties from the guacamole.properties
* file in the root of the classpath.
*
* @author Michael Jumper
*/
public class GuacamoleProperties { public class GuacamoleProperties {
private GuacamoleProperties() {} private GuacamoleProperties() {}
/**
* The hostname of the server where guacd (the Guacamole proxy server) is
* running.
*/
public static final StringGuacamoleProperty GUACD_HOSTNAME = new StringGuacamoleProperty() { public static final StringGuacamoleProperty GUACD_HOSTNAME = new StringGuacamoleProperty() {
@Override @Override
@@ -35,6 +45,9 @@ public class GuacamoleProperties {
}; };
/**
* The port that guacd (the Guacamole proxy server) is listening on.
*/
public static final IntegerGuacamoleProperty GUACD_PORT = new IntegerGuacamoleProperty() { public static final IntegerGuacamoleProperty GUACD_PORT = new IntegerGuacamoleProperty() {
@Override @Override
@@ -64,6 +77,18 @@ public class GuacamoleProperties {
} }
/**
* Given a GuacamoleProperty, parses and returns the value set for that
* property in guacamole.properties, if any.
*
* @param <Type> The type that the given property is parsed into.
* @param property The property to read from guacamole.properties.
* @return The parsed value of the property as read from
* guacamole.properties.
* @throws GuacamoleException If an error occurs while parsing the value
* for the given property in
* guacamole.properties.
*/
public static <Type> Type getProperty(GuacamoleProperty<Type> property) throws GuacamoleException { public static <Type> Type getProperty(GuacamoleProperty<Type> property) throws GuacamoleException {
if (exception != null) if (exception != null)

View File

@@ -21,11 +21,33 @@ import net.sourceforge.guacamole.GuacamoleException;
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/**
* An abstract representation of a property in the guacamole.properties file,
* which parses into a specific type.
*
* @author Michael Jumper
* @param <Type> The type this GuacamoleProperty will parse into.
*/
public interface GuacamoleProperty<Type> { public interface GuacamoleProperty<Type> {
/**
* Returns the name of the property in guacamole.properties that this
* GuacamoleProperty will parse.
*
* @return The name of the property in guacamole.properties that this
* GuacamoleProperty will parse.
*/
public String getName(); public String getName();
/**
* Parses the given string value into the type associated with this
* GuacamoleProperty.
*
* @param value The string value to parse.
* @return The parsed value.
* @throws GuacamoleException If an error occurs while parsing the
* provided value.
*/
public Type parseValue(String value) throws GuacamoleException; public Type parseValue(String value) throws GuacamoleException;
} }

View File

@@ -21,6 +21,11 @@ package net.sourceforge.guacamole.properties;
import net.sourceforge.guacamole.GuacamoleException; import net.sourceforge.guacamole.GuacamoleException;
/**
* A GuacamoleProperty whose value is an integer.
*
* @author Michael Jumper
*/
public abstract class IntegerGuacamoleProperty implements GuacamoleProperty<Integer> { public abstract class IntegerGuacamoleProperty implements GuacamoleProperty<Integer> {
@Override @Override

View File

@@ -21,6 +21,11 @@ package net.sourceforge.guacamole.properties;
import net.sourceforge.guacamole.GuacamoleException; import net.sourceforge.guacamole.GuacamoleException;
/**
* A GuacamoleProperty whose value is a simple string.
*
* @author Michael Jumper
*/
public abstract class StringGuacamoleProperty implements GuacamoleProperty<String> { public abstract class StringGuacamoleProperty implements GuacamoleProperty<String> {
@Override @Override