Statistics
| Branch: | Revision:

root / src / com / rackspace / cloud / servers / api / client / EntityList.java @ 35e7942d

History | View | Annotate | Download (1.3 kB)

1
/**
2
 * 
3
 */
4
package com.rackspace.cloud.servers.api.client;
5

    
6
import java.util.ArrayList;
7

    
8
/**
9
 * @author mike
10
 *
11
 */
12
public class EntityList {
13
        
14
        private long lastModified;
15
        private Entity entities[];
16
        private int index;
17

    
18
        public EntityList(ArrayList<Entity> entities) {
19
                this.entities = (Entity[]) entities.toArray();
20
                index = 0;
21
        }
22
                
23
        public EntityList(Entity entities[]) {
24
                this.entities = entities;
25
                index = 0;
26
        }
27
        
28
        public boolean isEmpty() {
29
                return entities == null || entities.length == 0;
30
        }
31
        
32
        public boolean hasNext() {
33
                if (isEmpty()) {
34
                        return false;
35
                } else {
36
                        if (index == entities.length - 1) {
37
                                // TODO: try to get more
38
                                return false;
39
                        } else {
40
                                return true;
41
                        }
42
                }
43
        }
44
        
45
        public Entity next() {
46
                if (hasNext()) {
47
                        return entities[index++];
48
                } else {
49
                        return null;
50
                }
51
        }
52
        
53
        public void reset() {
54
                entities = null;
55
                index = 0;
56
        }
57
        
58
        /**
59
         * @return the entities
60
         */
61
        public Entity[] getEntities() {
62
                return entities;
63
        }
64

    
65
        /**
66
         * @param entities the entities to set
67
         */
68
        public void setEntities(Entity[] entities) {
69
                this.entities = entities;
70
        }
71

    
72
        public void delta() {
73
                
74
        }
75
        
76
        /**
77
         * @return the lastModified
78
         */
79
        public long getLastModified() {
80
                return lastModified;
81
        }
82

    
83
        /**
84
         * @param lastModified the lastModified to set
85
         */
86
        public void setLastModified(long lastModified) {
87
                this.lastModified = lastModified;
88
        }
89

    
90
}