Skip to content

Package: Tuple

Tuple

Coverage

1: /**
2: * Copyright (C) 2016 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: package cz.cvut.kbss.jopa.model.query;
16:
17: import java.util.List;
18:
19: /**
20: * Interface for extracting the elements of a query result tuple.
21: */
22: public interface Tuple {
23:         /**
24:          * Get the value of the specified tuple element.
25:          *
26:          * @param tupleElement
27:          * tuple element
28:          * @return value of tuple element
29:          * @throws IllegalArgumentException
30:          * if tuple element
31:          *
32:          * does not correspond to an element in the
33:          *
34:          * query result tuple
35:          */
36:         <X> X get(TupleElement<X> tupleElement);
37:
38:         /**
39:          * Get the value of the tuple element to which the specified alias has been
40:          * assigned.
41:          *
42:          * @param alias
43:          * alias assigned to tuple element
44:          * @param type
45:          * of the tuple element
46:          * @return value of the tuple element
47:          * @throws IllegalArgumentException
48:          * if alias
49:          *
50:          * does not correspond to an element in the
51:          *
52:          * query result tuple or element cannot be
53:          *
54:          * assigned to the specified type
55:          */
56:         <X> X get(String alias, Class<X> type);
57:
58:         /**
59:          * Get the value of the tuple element to which the specified alias has been
60:          * assigned.
61:          *
62:          * @param alias
63:          * alias assigned to tuple element
64:          * @return value of the tuple element
65:          * @throws IllegalArgumentException
66:          * if alias
67:          *
68:          * does not correspond to an element in the
69:          *
70:          * query result tuple
71:          */
72:         Object get(String alias);
73:
74:         /**
75:          * Get the value of the element at the specified position in the result
76:          * tuple. The first position is 0.
77:          *
78:          * @param i
79:          * position in result tuple
80:          * @param type
81:          * type of the tuple element
82:          * @return value of the tuple element
83:          * @throws IllegalArgumentException
84:          * if i exceeds
85:          *
86:          * length of result tuple or element cannot be
87:          *
88:          * assigned to the specified type
89:          */
90:         <X> X get(int i, Class<X> type);
91:
92:         /**
93:          * Get the value of the element at the specified position in the result
94:          * tuple. The first position is 0.
95:          *
96:          * @param i
97:          * position in result tuple
98:          * @return value of the tuple element
99:          * @throws IllegalArgumentException
100:          * if i exceeds
101:          *
102:          * length of result tuple
103:          */
104:         Object get(int i);
105:
106:         /**
107:          * Return the values of the result tuple elements as an array.
108:          *
109:          * @return tuple element values
110:          */
111:         Object[] toArray();
112:
113:         /**
114:          * Return the tuple elements.
115:          *
116:          * @return tuple elements
117:          */
118:         List<TupleElement<?>> getElements();
119: }