PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

/webportal/src/main/java/au/org/emii/portal/util/LayerSelection.java

http://alageospatialportal.googlecode.com/
Java | 117 lines | 91 code | 18 blank | 8 comment | 13 complexity | 8df813c7fbf1dc1fa655d0bf8f85a610 MD5 | raw file
  1/*
  2 * To change this template, choose Tools | Templates
  3 * and open the template in the editor.
  4 */
  5package au.org.emii.portal.util;
  6
  7import java.text.SimpleDateFormat;
  8import java.util.ArrayList;
  9import java.util.Date;
 10
 11/**
 12 *
 13 * @author Adam
 14 */
 15public class LayerSelection {
 16
 17    String displayString;
 18    String layerName;
 19    String analysisType;
 20    long created;
 21    long lastUse;
 22    String layers;
 23    ArrayList<Long> analysisIds;
 24
 25    public LayerSelection(String displayString, String layersString) {
 26        this.displayString = displayString;
 27        this.layers = layersString;
 28    }
 29
 30    public LayerSelection(String analysisType, String layerName, long created, String layersString) {
 31        this.layerName = layerName;
 32        this.analysisType = analysisType;
 33        this.created = created;
 34        this.lastUse = created;
 35
 36        this.layers = layersString;
 37    }
 38
 39    public String getDisplayString() {
 40        return displayString;
 41    }
 42
 43    public String getLayerName() {
 44        return layerName;
 45    }
 46
 47    public String getAnalysisType() {
 48        return analysisType;
 49    }
 50
 51    public long getCreated() {
 52        return created;
 53    }
 54
 55    public void setLastUse(long lastUse) {
 56        this.lastUse = lastUse;
 57    }
 58
 59    public long getLastUse() {
 60        return lastUse;
 61    }
 62
 63    public boolean contains(String layerId) {
 64        String lookFor = "(" + layerId + ")";
 65        return layers.contains(lookFor);
 66    }
 67
 68    public String getLayers() {
 69        return layers;
 70    }
 71    
 72    @Override
 73    public String toString() {
 74        if(displayString != null) {
 75            return displayString;
 76        }
 77        
 78        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy hh:mm:ss");
 79        int len = layers.split(",").length;
 80        if (len != 1) {
 81            return layerName + " | " + sdf.format(new Date(created)) + " | " + len + " layers";
 82        } else {
 83            return layerName + " | " + sdf.format(new Date(created)) + " | " + len + " layer";
 84        }
 85    }
 86
 87    public boolean equalsList(LayerSelection ls) {
 88        String [] thisList = layers.split(",");
 89        String [] thatList = ls.layers.split(",");
 90
 91        for(int i=0;i<thisList.length;i++) {
 92            boolean found = false;
 93            for(int j=0;j<thatList.length;j++) {
 94                if(thisList[i].equals(thatList[j])) {
 95                    found = true;
 96                    break;
 97                }
 98            }
 99            if(!found) {
100                return false;
101            }
102        }
103        for(int j=0;j<thatList.length;j++) {
104            boolean found = false;
105            for(int i=0;i<thisList.length;i++) {
106                if(thisList[i].equals(thatList[j])) {
107                    found = true;
108                    break;
109                }
110            }
111            if(!found) {
112                return false;
113            }
114        }
115        return true;
116    }
117}