01: /*
02: * LICENSE INFORMATION
03: * Copyright 2005-2007 by FZI (http://www.fzi.de).
04: * Licensed under a BSD license (http://www.opensource.org/licenses/bsd-license.php)
05: * <OWNER> = Max Völkel
06: * <ORGANIZATION> = FZI Forschungszentrum Informatik Karlsruhe, Karlsruhe, Germany
07: * <YEAR> = 2007
08: *
09: * Project information at http://semweb4j.org/rdf2go
10: */
11: package org.ontoware.rdf2go.model.impl;
12:
13: import java.util.HashMap;
14: import java.util.Map;
15:
16: import org.ontoware.rdf2go.exception.ModelRuntimeException;
17: import org.ontoware.rdf2go.model.QueryRow;
18: import org.ontoware.rdf2go.model.node.Literal;
19: import org.ontoware.rdf2go.model.node.Node;
20:
21: public class QueryRowImpl extends HashMap<String, Node> implements
22: QueryRow {
23:
24: private static final long serialVersionUID = 1496910590032007736L;
25:
26: public Node getValue(String varname) {
27: return super .get(varname);
28: }
29:
30: public String getLiteralValue(String varname)
31: throws ModelRuntimeException {
32: Node n = super .get(varname);
33: if (n instanceof Literal)
34: return ((Literal) n).getValue();
35: //else
36: throw new ModelRuntimeException("Node is not a literal");
37: }
38:
39: @Override
40: public String toString() {
41: StringBuffer buf = new StringBuffer();
42:
43: for (Map.Entry<String, Node> entry : this .entrySet()) {
44: buf.append(entry.getKey()).append(":").append(
45: entry.getValue());
46: buf.append(", ");
47: }
48:
49: return buf.toString();
50: }
51:
52: }
|