Skip to content

Commit ec07548

Browse files
Change-Id: I224d394faee4fd4d3d7081bf8c58c82f23cb45b2
1 parent cd4b577 commit ec07548

1 file changed

Lines changed: 27 additions & 23 deletions

File tree

src/com/dtdsoftware/splunk/logging/SplunkLogEventFactory.java

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import java.util.Map;
55

66
/**
7-
* A factory class that allows you to set SplunkLogEvent templates and generate clones.
8-
* Useful for reuse when you log many events with the same key=value pair signatures.
7+
* A factory class that allows you to set SplunkLogEvent templates and generate
8+
* clones. Useful for reuse when you log many events with the same key=value
9+
* pair signatures.
910
*
1011
* <code>
1112
*
@@ -16,48 +17,51 @@
1617
* event.addPair("someparam", "helloworld");
1718
*
1819
* </code>
19-
*
20+
*
2021
* @author Damien Dallimore damien@dtdsoftware.com
21-
*
22+
*
2223
*/
2324
public abstract class SplunkLogEventFactory {
24-
25-
//map to hold the templates
26-
private static Map<String,SplunkLogEvent>templates = new HashMap<String,SplunkLogEvent>();
27-
25+
26+
// map to hold the templates
27+
private static Map<String, SplunkLogEvent> templates = new HashMap<String, SplunkLogEvent>();
28+
2829
/**
2930
* Add a template SplunkLogEvent object
31+
*
3032
* @param name
3133
* @param template
3234
*/
33-
public static void addTemplate(String name, SplunkLogEvent template){
34-
35+
public static void addTemplate(String name, SplunkLogEvent template) {
36+
3537
templates.put(name, template);
3638
}
37-
39+
3840
/**
3941
* Remove a template SplunkLogEvent object
42+
*
4043
* @param name
4144
*/
42-
public static void removeTemplate(String name){
43-
45+
public static void removeTemplate(String name) {
46+
4447
templates.remove(name);
4548
}
46-
49+
4750
/**
4851
* Get a new SplunkLogEvent object that is a clone of a template
52+
*
4953
* @param name
5054
* @return
5155
* @throws Exception
5256
*/
53-
public static SplunkLogEvent getInstanceFromTemplate(String name) throws Exception{
54-
55-
SplunkLogEvent template = templates.get(name);
56-
if(template != null){
57-
return template.clone();
58-
}
59-
else
60-
throw new Exception("SplunkLogEvent template "+name+" does not exist");
57+
public static SplunkLogEvent getInstanceFromTemplate(String name)
58+
throws Exception {
59+
60+
SplunkLogEvent template = templates.get(name);
61+
if (template != null) {
62+
return template.clone();
63+
} else
64+
throw new Exception("SplunkLogEvent template " + name
65+
+ " does not exist");
6166
}
6267
}
63-

0 commit comments

Comments
 (0)