-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d785260
commit 30e84c4
Showing
9 changed files
with
97 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2022 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2024 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
@@ -18,21 +18,24 @@ | |
|
||
package org.luwrain.core; | ||
|
||
import java.util.*; | ||
|
||
import org.luwrain.core.Job.*; | ||
|
||
import static org.luwrain.core.Job.*; | ||
import static org.luwrain.core.NullCheck.*; | ||
|
||
public class EmptyJobInstance implements Job.Instance | ||
{ | ||
protected final Listener listener; | ||
protected final String name; | ||
protected Map<String, List<String>> info = new HashMap<>(); | ||
private Status status = Status.RUNNING; | ||
private int exitCode = EXIT_CODE_INVALID; | ||
private String state = ""; | ||
private String[] multilineState = new String[0], nativeState = new String[0]; | ||
|
||
public EmptyJobInstance(Listener listener, String name) | ||
{ | ||
NullCheck.notEmpty(name, "name"); | ||
notEmpty(name, "name"); | ||
this.listener = listener; | ||
this.name = name; | ||
} | ||
|
@@ -64,50 +67,23 @@ public EmptyJobInstance(String name) | |
return this.status == Status.FINISHED && this.exitCode == EXIT_CODE_OK; | ||
} | ||
|
||
public void setSingleLineState(String value) | ||
public void setInfo(String infoType, List<String> value) | ||
{ | ||
NullCheck.notNull(value, "value"); | ||
notEmpty(infoType, "infoType"); | ||
notNull(value, "value"); | ||
if (this.status != Status.RUNNING) | ||
throw new IllegalStateException("The job '" + this.name + "' is not running"); | ||
this.state = value; | ||
this.info.put(infoType, value); | ||
if (this.listener != null) | ||
this.listener.onSingleLineStateChange(this); | ||
} | ||
|
||
@Override public String getSingleLineState() | ||
{ | ||
return this.state; | ||
} | ||
|
||
public void setMultilineState(String[] value) | ||
{ | ||
NullCheck.notNullItems(value, "value"); | ||
if (this.status != Status.RUNNING) | ||
throw new IllegalStateException("The job '" + this.name + "' is not running"); | ||
this.multilineState = value.clone(); | ||
if (this.listener != null) | ||
this.listener.onMultilineStateChange(this); | ||
this.listener.onInfoChange(this, infoType, value); | ||
} | ||
|
||
@Override public String[] getMultilineState() | ||
@Override public List<String> getInfo(String infoType) | ||
{ | ||
return this.multilineState.clone(); | ||
} | ||
|
||
public void setNativeState(String[] value) | ||
{ | ||
NullCheck.notNullItems(value, "value"); | ||
if (this.status != Status.RUNNING) | ||
throw new IllegalStateException("The job '" + this.name + "' is not running"); | ||
this.nativeState = value.clone(); | ||
if (this.listener != null) | ||
this.listener.onNativeStateChange(this); | ||
} | ||
|
||
@Override public String[] getNativeState() | ||
{ | ||
return this.nativeState.clone(); | ||
} | ||
notEmpty(infoType, "infoType"); | ||
final var res = this.info.get(infoType); | ||
return res != null?res:Arrays.asList(); | ||
} | ||
|
||
public void stop(int exitCode) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2022 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2024 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
@@ -14,19 +14,12 @@ | |
General Public License for more details. | ||
*/ | ||
|
||
//LWR_API 1.0 | ||
|
||
package org.luwrain.core; | ||
|
||
import java.util.List; | ||
|
||
import org.luwrain.core.Job.Instance; | ||
import java.util.*; | ||
|
||
public class EmptyJobListener implements Job.Listener | ||
{ | ||
@Override public void onInfoChange(Job.Instance instance, String type, List<String> value){} | ||
@Override public void onStatusChange(Instance instance) {} | ||
@Override public void onSingleLineStateChange(Instance instance) {} | ||
@Override public void onMultilineStateChange(Instance instance) {} | ||
@Override public void onNativeStateChange(Instance instance) {} | ||
@Override public void onStatusChange(Job.Instance instance) {} | ||
@Override public void onInfoChange(Job.Instance instance, String infoType, List<String> value) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2022 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2024 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
@@ -14,19 +14,21 @@ | |
General Public License for more details. | ||
*/ | ||
|
||
//LWR_API 1.0 | ||
|
||
package org.luwrain.core; | ||
|
||
public final class ErrorJob implements Job.Instance | ||
import java.util.*; | ||
|
||
import static org.luwrain.core.NullCheck.*; | ||
|
||
public final class ErrorJobInstance implements Job.Instance | ||
{ | ||
private final String name; | ||
private final String message; | ||
|
||
public ErrorJob(String name, String message) | ||
public ErrorJobInstance(String name, String message) | ||
{ | ||
NullCheck.notEmpty(name, "name"); | ||
NullCheck.notEmpty(message, "message"); | ||
notEmpty(name, "name"); | ||
notEmpty(message, "message"); | ||
this.name = name; | ||
this.message = message; | ||
} | ||
|
@@ -55,18 +57,11 @@ public ErrorJob(String name, String message) | |
return false; | ||
} | ||
|
||
@Override public String getSingleLineState() | ||
{ | ||
return message; | ||
} | ||
|
||
@Override public String[] getMultilineState() | ||
{ | ||
return new String[]{message}; | ||
} | ||
|
||
@Override public String[] getNativeState() | ||
@Override public List<String> getInfo(String infoType) | ||
{ | ||
return new String[]{message}; | ||
notEmpty(infoType, "infoType"); | ||
if (infoType.equals("main")) | ||
return Arrays.asList(message); | ||
return Arrays.asList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
Copyright 2012-2024 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
LUWRAIN is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public | ||
License as published by the Free Software Foundation; either | ||
version 3 of the License, or (at your option) any later version. | ||
LUWRAIN is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
General Public License for more details. | ||
*/ | ||
|
||
package org.luwrain.core.events; | ||
|
||
import org.luwrain.core.*; | ||
|
||
public final class UpdateEvent extends Event | ||
{ | ||
public UpdateEvent() | ||
{ | ||
} | ||
} |
Oops, something went wrong.