public static Value convertTagToValue(String tagName, String tagValue) { if (tagName.equals(TagConstants.NAME_OBJECT) || tagName.equals(TagConstants.NAME_SERVICE) || tagName.equals(TagConstants.NAME_SERVICE_ELAPSED) || tagName.equals(TagConstants.NAME_SERVICE_BYTES) || tagName.equals(TagConstants.NAME_SERVICE_ERRORS) || tagName.equals(TagConstants.NAME_GROUP) || tagName.equals(TagConstants.NAME_USER_AGENT) || tagName.equals(TagConstants.NAME_REFERER) || tagName.equals(TagConstants.NAME_CITY) || tagName.equals(TagConstants.NAME_ERROR)) { return new TextHashValue(tagValue); } else if (tagName.equals(TagConstants.NAME_VISITOR) || tagName.equals(TagConstants.NAME_ELAPSED) || tagName.equals(TagConstants.NAME_SQLTIME) || tagName.equals(TagConstants.NAME_APITIME)) { return new DecimalValue(Long.valueOf(tagValue)); } else if (tagName.equals(TagConstants.NAME_LEVEL)) { return new DecimalValue(AlertLevel.getValue(tagValue)); } else if (tagName.equals(TagConstants.NAME_IP)) { return new IP4Value(tagValue); } return new TextValue(tagValue); }
// This should be called background thread. public static List<String> loadTagString( int serverId, String date, List<Value> vList, String tagName) { List<String> resultList = new ArrayList<String>(); if (vList.size() == 0) return resultList; Value sample = vList.get(0); switch (sample.getValueType()) { case ValueEnum.TEXT_HASH: ListValue lv = new ListValue(); for (Value v : vList) { lv.add(CastUtil.cint(v.toJavaObject())); } if (tagName.equals(TagConstants.NAME_OBJECT)) { TextProxy.object.load(date, lv, serverId); for (int i = 0; i < lv.size(); i++) { resultList.add(TextProxy.object.getText(lv.getInt(i))); } } else if (tagName.equals(TagConstants.NAME_SERVICE) || tagName.equals(TagConstants.NAME_SERVICE_ELAPSED) || tagName.equals(TagConstants.NAME_SERVICE_BYTES) || tagName.equals(TagConstants.NAME_SERVICE_ERRORS)) { TextProxy.service.load(date, lv, serverId); for (int i = 0; i < lv.size(); i++) { resultList.add(TextProxy.service.getText(lv.getInt(i))); } } else if (tagName.equals(TagConstants.NAME_USER_AGENT)) { TextProxy.userAgent.load(date, lv, serverId); for (int i = 0; i < lv.size(); i++) { resultList.add(TextProxy.userAgent.getText(lv.getInt(i))); } } else if (tagName.equals(TagConstants.NAME_GROUP)) { TextProxy.group.load(date, lv, serverId); for (int i = 0; i < lv.size(); i++) { resultList.add(TextProxy.group.getText(lv.getInt(i))); } } else if (tagName.equals(TagConstants.NAME_CITY)) { TextProxy.city.load(date, lv, serverId); for (int i = 0; i < lv.size(); i++) { resultList.add(TextProxy.city.getText(lv.getInt(i))); } } else if (tagName.equals(TagConstants.NAME_REFERER)) { TextProxy.referer.load(date, lv, serverId); for (int i = 0; i < lv.size(); i++) { resultList.add(TextProxy.referer.getText(lv.getInt(i))); } } else if (tagName.equals(TagConstants.NAME_ERROR)) { TextProxy.error.load(date, lv, serverId); for (int i = 0; i < lv.size(); i++) { resultList.add(TextProxy.error.getText(lv.getInt(i))); } } break; case ValueEnum.DECIMAL: if (tagName.equals(TagConstants.NAME_LEVEL)) { for (Value v : vList) { resultList.add(AlertLevel.getName((byte) ((DecimalValue) v).value)); } } else { for (Value v : vList) { resultList.add(CastUtil.cString(v.toJavaObject())); } } break; case ValueEnum.IP4ADDR: for (Value v : vList) { resultList.add(v.toString()); } break; case ValueEnum.TEXT: for (Value v : vList) { resultList.add(v.toString()); } break; default: for (Value v : vList) { resultList.add(v.toString()); } break; } return resultList; }