forked from highsource/jaxb-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
83 lines (71 loc) · 2.31 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package com.workday.bsvo;
import java.io.File;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Unmarshaller;
import com.workday.Root;
/**
* Example of unmarshalling a PutAbsenceInputRequest
*/
public class Main
{
public static final String SAMPLE_WD_FILE = "src/test/samples/workday-01.xml";
private static Logger logger = LoggerFactory.getLogger(Main.class);
public static Logger getLogger() { return logger; }
private JAXBContext jaxbContext;
public JAXBContext getJaxbContext() throws JAXBException
{
if ( jaxbContext == null )
setJaxbContext(JAXBContext.newInstance(com.workday.ObjectFactory.class));
return jaxbContext;
}
public void setJaxbContext(JAXBContext jaxbContext)
{
this.jaxbContext = jaxbContext;
}
private Unmarshaller unmarshaller = null;
protected Unmarshaller getUnmarshaller() throws JAXBException
{
if ( unmarshaller == null )
setUnmarshaller(getJaxbContext().createUnmarshaller());
return unmarshaller;
}
protected void setUnmarshaller(Unmarshaller unmarshaller)
{
this.unmarshaller = unmarshaller;
}
// Represents the unmarshalled PutAbsenceInputRequest.
private PutAbsenceInputRequest putAbsenceInputRequest = null;
public PutAbsenceInputRequest getPutAbsenceInputRequest() { return putAbsenceInputRequest; }
public void setPutAbsenceInputRequest(PutAbsenceInputRequest putAbsenceInputRequest) { this.putAbsenceInputRequest = putAbsenceInputRequest; }
/**
* Command Line Invocation.
* @param args CLI argument(s)
*/
public static void main(String[] args) throws Exception
{
String path = args.length > 0 ? args[0] : SAMPLE_WD_FILE;
Main main = new Main();
main.execute(path);
}
private void execute(String path) throws JAXBException
{
File xmlFile = new File(path);
Root root = (Root) getUnmarshaller().unmarshal(xmlFile);
setPutAbsenceInputRequest(root.getPutAbsenceInputRequest());
println("PutAbsenceInputRequest: "
+ getPutAbsenceInputRequest().getAbsenceInputData().getBatchID() + "\n\n"
+ getPutAbsenceInputRequest() + "\n");
}
/**
* Print a text string.
* @param text The text to be printed.
*/
public static void println(String text)
{
getLogger().info(text);
}
}
// vi:set tabstop=4 hardtabs=4 shiftwidth=4: