Assume I have this kind of file
SCHEDULE AEP#GSAE3_SCO_D99008 TIMEZONE ECT
DESCRIPTION "APOLLO_ MQFT SENDING JOBS"
ON RUNCYCLE RULE1 "FREQ=DAILY;"
:
AEP#GSAE3_SCO_D99008_ASUP_ORD_V4
SCRIPTNAME "-job Z3_SCO_D99008_ASUP_ORD_V4 -user BECKDEL1 -i 04093800 -c C"
STREAMLOGON batchatl
DESCRIPTION "Take Customer Order to be send in MQFT format"
TASKTYPE SAP
RECOVERY STOP
AT 2145 TIMEZONE ECT
NEEDS 1 AEP#GSAE_SCO
...
END
This is file from TWS (Tivoli Workload Scheduler). What I want to get is JSON or XML file looks like:
{
"Jobstream":"AEP#GSAE3_SCO_D99008",
"Timezone": "ECT",
"Description": "APOLLO_ MQFT SENDING JOBS",
"Jobs": {[
"Job": "AEP#GSAE3_SCO_D99008_ASUP_ORD_V4",
"SAP_JOB": "Z3_SCO_D99008_ASUP_ORD_V4",
"SAP_USER": "BECKDEL1",
"Id": 04093800,
"Streamlogon": "batchatl",
"Description": "Take Customer Order to be send in MQFT format",
"Tasktype": "SAP",
"Recovery": "STOP",
"AT": 2145,
"TIMEZONE": "ECT"
],[...]}
What I need to read to understand how can I parse this kind of file? I tried to use BufferReader and Scanner in Java. I already have 2 Java classes: JobStream and Job. JobStream:
public class Jobstream {
private String name;
private String timeZone;
private String description;
private ArrayList<Job> jobs;
public Jobstream(String name, String timeZone, String description) {
this.name = name;
this.timeZone = timeZone;
this.description = description;
this.jobs = new ArrayList<>();
}
public void appendJob(Job job) {
this.jobs.add(job);
}
}
And Job:
public class Job {
private String name;
private String sapName;
private String sapUser;
private int id;
private String logon;
private String description;
private String type;
private String recovery;
private int at;
private String timezone;
public Job(String name, String sapName, String sapUser,
int id, String logon, String description,
String type, String recovery, int at, String timezone) {
this.name = name;
this.sapName = sapName;
this.sapUser = sapUser;
this.id = id;
this.logon = logon;
this.description = description;
this.type = type;
this.recovery = recovery;
this.at = at;
this.timezone = timezone;
}
}
So that's structure.
It will be awesome if you tell me the way I can make it.
Have a nice day!
P.S. I'm NOT asking to help me to write a parser. I'm just asking to help me to find information I need to write it by MYSELF.