Skip to content

Package: Tuple

Tuple

Coverage

1: /**
2: * Copyright (C) 2011 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15:
16: package cz.cvut.kbss.jopa.model.query;
17:
18: import java.util.List;
19:
20: /**
21: * Interface for extracting the elements of a query result tuple.
22: */
23: public interface Tuple {
24:         /**
25:          * Get the value of the specified tuple element.
26:          *
27:          * @param tupleElement
28:          * tuple element
29:          * @return value of tuple element
30:          * @throws IllegalArgumentException
31:          * if tuple element
32:          *
33:          * does not correspond to an element in the
34:          *
35:          * query result tuple
36:          */
37:         <X> X get(TupleElement<X> tupleElement);
38:
39:         /**
40:          * Get the value of the tuple element to which the specified alias has been
41:          * assigned.
42:          *
43:          * @param alias
44:          * alias assigned to tuple element
45:          * @param type
46:          * of the tuple element
47:          * @return value of the tuple element
48:          * @throws IllegalArgumentException
49:          * if alias
50:          *
51:          * does not correspond to an element in the
52:          *
53:          * query result tuple or element cannot be
54:          *
55:          * assigned to the specified type
56:          */
57:         <X> X get(String alias, Class<X> type);
58:
59:         /**
60:          * Get the value of the tuple element to which the specified alias has been
61:          * assigned.
62:          *
63:          * @param alias
64:          * alias assigned to tuple element
65:          * @return value of the tuple element
66:          * @throws IllegalArgumentException
67:          * if alias
68:          *
69:          * does not correspond to an element in the
70:          *
71:          * query result tuple
72:          */
73:         Object get(String alias);
74:
75:         /**
76:          * Get the value of the element at the specified position in the result
77:          * tuple. The first position is 0.
78:          *
79:          * @param i
80:          * position in result tuple
81:          * @param type
82:          * type of the tuple element
83:          * @return value of the tuple element
84:          * @throws IllegalArgumentException
85:          * if i exceeds
86:          *
87:          * length of result tuple or element cannot be
88:          *
89:          * assigned to the specified type
90:          */
91:         <X> X get(int i, Class<X> type);
92:
93:         /**
94:          * Get the value of the element at the specified position in the result
95:          * tuple. The first position is 0.
96:          *
97:          * @param i
98:          * position in result tuple
99:          * @return value of the tuple element
100:          * @throws IllegalArgumentException
101:          * if i exceeds
102:          *
103:          * length of result tuple
104:          */
105:         Object get(int i);
106:
107:         /**
108:          * Return the values of the result tuple elements as an array.
109:          *
110:          * @return tuple element values
111:          */
112:         Object[] toArray();
113:
114:         /**
115:          * Return the tuple elements.
116:          *
117:          * @return tuple elements
118:          */
119:         List<TupleElement<?>> getElements();
120: }