/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

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