KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > medor > query > lib > BasicOrderField


1 /**
2  * MEDOR: Middleware Enabling Distributed Object Requests
3  *
4  * Copyright (C) 2001-2003 France Telecom R&D
5  * Contact: alexandre.lefebvre@rd.francetelecom.com
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  * Initial developers: M. Alia, A. Lefebvre, S. Chassande-Barrioz
22  */

23
24 package org.objectweb.medor.query.lib;
25
26 import org.objectweb.medor.query.api.OrderField;
27 import org.objectweb.medor.query.api.QueryTreeField;
28 import org.objectweb.medor.clone.lib.BasicCloneable;
29
30 import java.util.Map JavaDoc;
31
32 /**
33  * @author Alexandre Lefebvre
34  */

35 public class BasicOrderField extends BasicCloneable implements OrderField {
36
37     private boolean desc = false;
38
39     private QueryTreeField field;
40
41     public BasicOrderField() {
42     }
43
44     /**
45      * Constructs a BasicOrderField from a QueryTreeField.
46      * <p>The default value for ordering is ascendant.
47      * @param field the QueryTreeField on which to build the ordering.
48      */

49     public BasicOrderField(QueryTreeField field) {
50         this.field = field;
51     }
52
53     /**
54      * Constructs a BasciOrderField from a QueryTreeField, with indication
55      * of ordering.
56      * @param field the QueryTreeField on which to build the ordering
57      * @param desc the boolean indicating whether the ordering should be
58      * descendant (true) or ascendant (false).
59      */

60     public BasicOrderField(QueryTreeField field, boolean desc) {
61         this.field = field;
62         this.desc = desc;
63     }
64
65     public Object JavaDoc clone(Object JavaDoc clone,
66                         Map JavaDoc obj2clone) throws CloneNotSupportedException JavaDoc {
67         clone = super.clone(clone, obj2clone);
68         ((BasicOrderField) clone).desc = desc;
69         ((BasicOrderField) clone).field = (QueryTreeField) getClone(field, obj2clone);
70         return clone;
71     }
72
73     public void setField(QueryTreeField field) {
74         this.field = field;
75     }
76
77     public QueryTreeField getField() {
78         return field;
79     }
80
81     public void setDesc(boolean desc) {
82         this.desc = desc;
83     }
84
85     public boolean getDesc() {
86         return desc;
87     }
88 }
89
Popular Tags