This repository has been archived by the owner on Apr 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 290
/
AbstractToolOperation2.java
44 lines (35 loc) · 1.72 KB
/
AbstractToolOperation2.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
/*******************************************************************************
* Copyright (c) 2016 Bruno Medeiros and other Contributors.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Bruno Medeiros - initial API and implementation
*******************************************************************************/
package melnorme.lang.tooling.ops;
import melnorme.utilbox.concurrency.OperationCancellation;
import melnorme.utilbox.core.CommonException;
import melnorme.utilbox.misc.StringUtil;
import melnorme.utilbox.process.ExternalProcessHelper.ExternalProcessResult;
public abstract class AbstractToolOperation2<RESULT> extends ToolOutputParseHelper {
public AbstractToolOperation2() {
super();
}
public RESULT handleProcessResult(ExternalProcessResult result)
throws CommonException, OperationCancellation, OperationSoftFailure {
if(result.exitValue != 0) {
handleNonZeroExitCode(result);
}
return doHandleProcessResult(result);
}
protected abstract void handleNonZeroExitCode(ExternalProcessResult result)
throws CommonException, OperationCancellation, OperationSoftFailure;
protected RESULT doHandleProcessResult(ExternalProcessResult result)
throws CommonException, OperationCancellation, OperationSoftFailure {
return handleProcessOutput(result.getStdOutBytes().toString(StringUtil.UTF8));
}
protected abstract RESULT handleProcessOutput(String output)
throws CommonException, OperationCancellation, OperationSoftFailure;
}