newest quantum CVS sources
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / model / IndexImpl.java
1 package com.quantum.model;
2
3 import java.util.ArrayList;
4 import java.util.Collections;
5 import java.util.List;
6
7 /**
8  * @author BC
9  */
10 /*package*/ class IndexImpl implements Index {
11     
12     private String name;
13     private List columnNames = Collections.synchronizedList(new ArrayList()); 
14     private Entity entity;
15     private List ascending = Collections.synchronizedList(new ArrayList());
16     
17     IndexImpl(Entity entity, String name) {
18             
19         this.name = name;
20         this.entity = entity;
21     }
22     
23     void addColumn(String columnName, Boolean ascending) {
24         this.columnNames.add(columnName);
25         this.ascending.add(ascending);
26     }
27
28     public String getName() {
29         return this.name;
30     }
31
32     /**
33      * @see com.quantum.model.Index#getNumberOfColumns()
34      */
35     public int getNumberOfColumns() {
36         return this.columnNames.size();
37     }
38
39     /**
40      * @see com.quantum.model.Index#getColumnName(int)
41      */
42     public String getColumnName(int ordinalPosition) {
43         return (String) this.columnNames.get(ordinalPosition);
44     }
45
46     /**
47      * @see com.quantum.model.Index#getParentEntity()
48      */
49     public Entity getParentEntity() {
50         return this.entity;
51     }
52
53     /**
54      * @see com.quantum.model.Index#isAscending()
55      */
56     public boolean isAscending(int ordinalPosition) {
57         Boolean ascending = (Boolean) this.ascending.get(ordinalPosition);
58         return Boolean.TRUE.equals(ascending);
59     }
60
61     /**
62      * @see com.quantum.model.Index#isDescending()
63      */
64     public boolean isDescending(int ordinalPosition) {
65         Boolean ascending = (Boolean) this.ascending.get(ordinalPosition);
66         return Boolean.FALSE.equals(ascending);
67     }
68
69 }