diff options
author | Matt Windsor <matt@deling.(none)> | 2011-03-18 08:28:09 +0000 |
---|---|---|
committer | Matt Windsor <matt@deling.(none)> | 2011-03-18 08:28:09 +0000 |
commit | d547f87da5f68c12dede7c9d45618cae11ff5699 (patch) | |
tree | 613aa95d94b363c72ba9a7be639c74f76edf81f8 /src/uk/org/ury/database/DatabaseItem.java | |
parent | c8bb324e757587e742df0824304144e1eb881cee (diff) |
Mega-commit to the rescue! Added Javadoc snapshot (admittedly old); show UI now fixed-layout; UI uses system selection colours for accents; now uses bapsserver password and can thus talk to show database relations; removed member relation dependencies until further notice; attempted to get application and applet launchers working but having issues with the latter; started working on a server communicating via a minimal implementation of HTTP 1.1 (standardisation required eventually).
Diffstat (limited to 'src/uk/org/ury/database/DatabaseItem.java')
-rw-r--r-- | src/uk/org/ury/database/DatabaseItem.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/uk/org/ury/database/DatabaseItem.java b/src/uk/org/ury/database/DatabaseItem.java index 4f6d34d..f151dbf 100644 --- a/src/uk/org/ury/database/DatabaseItem.java +++ b/src/uk/org/ury/database/DatabaseItem.java @@ -1,8 +1,11 @@ package uk.org.ury.database; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import uk.org.ury.database.exceptions.MissingPropertyException; +import uk.org.ury.server.protocol.Directive; /** @@ -21,6 +24,7 @@ public abstract class DatabaseItem<E, T> { private Map<E, T> properties; + /** * Construct a new item from an existing list of properties. * @@ -67,4 +71,30 @@ public abstract class DatabaseItem<E, T> else throw new MissingPropertyException (property.toString ()); } + + + /** + * Map down the item into a server response body. + * + * This relies on E and T having meaningful toString methods. + * + * @return a list of lines representing the response. + */ + + public List<String> + asResponse () + { + // TODO: Fan out implementation details into separate class + + List<String> response = new ArrayList<String> (); + + for (E property : properties.keySet ()) + { + if (properties.get (property) != null) + response.add (property.toString () + ": " + + properties.get (property).toString ()); + } + + return response; + } } |