PageRenderTime 67ms CodeModel.GetById 56ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/edu/uncc/parsets/data/OnlineDataSet.java

https://code.google.com/p/parsets/
Java | 120 lines | 67 code | 21 blank | 32 comment | 0 complexity | 19fa6fbb1ceba532280aff9c0666f856 MD5 | raw file
  1package edu.uncc.parsets.data;
  2
  3import edu.uncc.parsets.parsets.SelectionChangeEvent;
  4import java.util.Iterator;
  5import java.util.List;
  6import java.util.Map;
  7
  8import javax.swing.tree.DefaultMutableTreeNode;
  9
 10/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
 11 * Copyright (c) 2009, Robert Kosara, Caroline Ziemkiewicz,
 12 *                     and others (see Authors.txt for full list)
 13 * All rights reserved.
 14 * 
 15 * Redistribution and use in source and binary forms, with or without
 16 * modification, are permitted provided that the following conditions are met:
 17 * 
 18 *    * Redistributions of source code must retain the above copyright
 19 *      notice, this list of conditions and the following disclaimer.
 20 *    * Redistributions in binary form must reproduce the above copyright
 21 *      notice, this list of conditions and the following disclaimer in the
 22 *      documentation and/or other materials provided with the distribution.
 23 *    * Neither the name of UNC Charlotte nor the names of its contributors
 24 *      may be used to endorse or promote products derived from this software
 25 *      without specific prior written permission.
 26 *      
 27 * THIS SOFTWARE IS PROVIDED BY ITS AUTHORS ''AS IS'' AND ANY
 28 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 29 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 30 * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
 31 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 32 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 33 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 34 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 36 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 37\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 38
 39/**
 40 * Minimal wrapper around parsed JSON data to represent online datasets that
 41 * can be downloaded.
 42 */
 43public class OnlineDataSet extends DataSet {
 44
 45	private Map<String, Object> jsonData;
 46	private String handle;
 47		
 48	public OnlineDataSet(String dsHandle, Map<String, Object> jsonObject) {
 49		jsonData = jsonObject;
 50		handle = dsHandle;
 51		name = (String)jsonData.get("name");
 52	}
 53
 54	@Override
 55	public String getHandle() {
 56		return handle;
 57	}
 58	
 59	@Override
 60	public DefaultMutableTreeNode getCategoricalDimensionsAsTree() {
 61		return null;
 62	}
 63
 64	@Override
 65	public int getNumCategoricalDimensions() {
 66		return ((Long)jsonData.get("categorical")).intValue();
 67	}
 68
 69	@Override
 70	public int getNumDimensions() {
 71		return getNumCategoricalDimensions()+getNumNumericDimensions();
 72	}
 73
 74	@Override
 75	public int getNumNumericDimensions() {
 76		return ((Long)jsonData.get("numerical")).intValue();
 77	}
 78
 79	@Override
 80	public int getNumRecords() {
 81		return ((Long)jsonData.get("items")).intValue();
 82	}
 83
 84	@Override
 85	public DimensionHandle[] getNumericDimensions() {
 86		return null;
 87	}
 88
 89	@Override
 90	public String getSection() {
 91		return (String)jsonData.get("section");
 92	}
 93
 94	public String getSource() {
 95		return (String)jsonData.get("source");
 96	}
 97
 98	public String getSrcURL() {
 99		return (String)jsonData.get("srcURL");
100	}
101
102	@Override
103	public CategoryTree getTree(List<DimensionHandle> dimensions) {
104		return null;
105	}
106
107	@Override
108	public String getURL() {
109		return (String)jsonData.get("url");
110	}
111
112	@Override
113	public Iterator<DimensionHandle> iterator() {
114		return null;
115	}
116
117    public void selectionChanged(SelectionChangeEvent event) {
118        
119    }
120}