001: /*
002: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005: package com.sun.portal.ubt.report.data;
006:
007: import java.util.HashMap;
008: import java.util.Properties;
009:
010: /**
011: * Maps the fields to the value in a log line.
012: *
013: */
014: public class UBTLogFileLine implements UBTLogLine {
015: protected static Properties ubtLabels = null;
016: protected static HashMap ubtLabelIndexMap = new HashMap();
017: protected String[] labelValues = null;
018:
019: public String[] getLabelValues() {
020: return labelValues;
021: }
022:
023: public UBTLogFileLine(String[] logLine)
024: throws LabelsNoDataException {
025: if (logLine.length > 0) {
026: if (logLine[0].startsWith("!")) {
027: //you have new set of labels or log file closed and opened
028: logLine[0] = logLine[0].substring(logLine[0]
029: .indexOf(":") + 2);
030: ubtLabelIndexMap = new HashMap();
031: for (int i = 0; i < logLine.length; i++) {
032: ubtLabelIndexMap.put(logLine[i], new Integer(i));
033: }
034: throw new LabelsNoDataException();
035: }
036: }
037: labelValues = logLine;
038: }
039:
040: public HashMap getLabelIndexMap() {
041: return ubtLabelIndexMap;
042: }
043:
044: private String getVal(String label) {
045: String val = null;
046: try {
047: val = labelValues[((Integer) ubtLabelIndexMap.get(label))
048: .intValue()];
049: } catch (Exception e) {
050: //fall through, data field does not exist
051: }
052: if (val != null && val.equals("-")) {
053: return null;
054: } else {
055: return val;
056: }
057: }
058:
059: public String getTimestamp() {
060: return getVal("Timestamp");
061: }
062:
063: public String getPortalID() {
064: return getVal("PortalID");
065: }
066:
067: public String getLevel() {
068: return getVal("Level");
069: }
070:
071: public String getUserID() {
072: return getVal("UserID");
073: }
074:
075: public String getEventID() {
076: return getVal("EventID");
077: }
078:
079: public String getComponentName() {
080: return getVal("ComponentName");
081: }
082:
083: public String getChannelName() {
084: return getVal("ChannelName");
085: }
086:
087: public String getProvider() {
088: return getVal("Provider");
089: }
090:
091: public String getTargetProvider() {
092: return getVal("TargetProvider");
093: }
094:
095: public String getContainerName() {
096: return getVal("ContainerName");
097: }
098:
099: public String getAction() {
100: return getVal("Action");
101: }
102:
103: public String getEntityID() {
104: return getVal("EntityID");
105: }
106:
107: public String getMode() {
108: return getVal("Mode");
109: }
110:
111: public String getWindowState() {
112: return getVal("WindowState");
113: }
114:
115: public String getExPortalLink() {
116: return getVal("ExPortalLink");
117: }
118:
119: public String getClientHost() {
120: return getVal("ClientHost");
121: }
122:
123: public String getClientIP() {
124: return getVal("ClientIP");
125: }
126:
127: public String getServerHost() {
128: return getVal("ServerHost");
129: }
130:
131: public String getServerPort() {
132: return getVal("ServerPort");
133: }
134:
135: public String getRequestHeader() {
136: return getVal("RequestHeader");
137: }
138:
139: public String get(String field) {
140: return getVal(field);
141: }
142: }
|