resultset row / col
This commit is contained in:
snoop 2017-04-25 16:36:53 +09:00
parent 4501f9eac4
commit 6c8cb4bd21
3 changed files with 97 additions and 52 deletions

View File

@ -10,11 +10,11 @@ import java.util.Map;
/**
* Created by root on 17. 4. 25.
*/
public class OFResultSet {
public abstract class OFResultSet {
private Item item;
private List<List<String>> rows;
private Map<String, Integer> meta = null;
protected Item item;
protected List<List<String>> rows;
protected Map<String, Integer> meta = null;
public Map<String, Integer> getMeta() {
return meta;
@ -41,40 +41,8 @@ public class OFResultSet {
}
public void setMeta() {
String type = (String) this.item.getQuery().getQueryInfo().get("parseDirection");
List<String> meta = new ArrayList<>();
if (type.equals("row")) {
List<String> arrayColumns = (List<String>) this.item.getQuery().getQueryInfo().get("arrayColumns");
List<String> keyColumns = (List<String>) this.item.getQuery().getQueryInfo().get("keyColumns");
String valueColumn = (String) this.item.getQuery().getQueryInfo().get("valueColumn");
for (String c : arrayColumns) {
meta.add(c);
}
for (String c: keyColumns) {
meta.add(c);
}
meta.add(valueColumn);
} else {
}
if(this.meta == null) {
this.meta = new HashMap<>();
}
for(int indexI = 0; indexI < meta.size(); ++indexI) {
this.meta.put(meta.get(indexI), indexI);
}
}
public OFResultSet(Item item) {
this.item = item;
this.rows = new ArrayList<>();
@ -87,25 +55,12 @@ public class OFResultSet {
public Map<String,String> getData() {
String type = (String) this.item.getQuery().getQueryInfo().get("parseType");
if (type.equals("row")) {
return parseRow();
} else {
return parseCol();
}
return parse();
}
public Map<String, String> parseCol() {
public abstract void setMeta();
public abstract Map<String, String> parse();
return null;
}
public Map<String, String> parseRow() {
return null;
}
}

View File

@ -0,0 +1,39 @@
package com.loafle.overflow.crawler.result;
import com.loafle.overflow.crawler.config.Item;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by root on 17. 4. 25.
*/
public class OFResultSetCol extends OFResultSet{
public OFResultSetCol(Item item) {
super(item);
}
public void setMeta() {
List<String> meta = this.item.getQuery().getKeys();
if(this.meta == null) {
this.meta = new HashMap<>();
}
for(int indexI = 0; indexI < meta.size(); ++indexI) {
this.meta.put(meta.get(indexI), indexI);
}
}
public Map<String, String> parse() {
return null;
}
}

View File

@ -0,0 +1,51 @@
package com.loafle.overflow.crawler.result;
import com.loafle.overflow.crawler.config.Item;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by root on 17. 4. 25.
*/
public class OFResultSetRow extends OFResultSet{
public OFResultSetRow(Item item) {
super(item);
}
public void setMeta() {
List<String> meta = new ArrayList<>();
List<String> arrayColumns = (List<String>) this.item.getQuery().getQueryInfo().get("arrayColumns");
List<String> keyColumns = (List<String>) this.item.getQuery().getQueryInfo().get("keyColumns");
String valueColumn = (String) this.item.getQuery().getQueryInfo().get("valueColumn");
for (String c : arrayColumns) {
meta.add(c);
}
for (String c: keyColumns) {
meta.add(c);
}
meta.add(valueColumn);
if(this.meta == null) {
this.meta = new HashMap<>();
}
for(int indexI = 0; indexI < meta.size(); ++indexI) {
this.meta.put(meta.get(indexI), indexI);
}
}
public Map<String, String> parse() {
return null;
}
}