mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 00:50:31 +00:00
Fixes
This commit is contained in:
parent
8d95f451bb
commit
4216528a87
12 changed files with 89 additions and 25 deletions
|
@ -9,7 +9,7 @@ apply from: "$rootDir/deps/java.gradle"
|
|||
apply from: "$rootDir/deps/junit.gradle"
|
||||
|
||||
System.setProperty('excludeExtensionLibrary', 'true')
|
||||
apply from: "$rootDir/scripts/extension_test.gradle"
|
||||
apply from: "$rootDir/deps/extension_test.gradle"
|
||||
|
||||
version = file('../misc/version').text
|
||||
group = 'io.xpipe'
|
||||
|
|
|
@ -19,6 +19,10 @@ public class BeaconFormat {
|
|||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (isClosed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
finishBlock();
|
||||
out.flush();
|
||||
index = -1;
|
||||
|
@ -26,6 +30,10 @@ public class BeaconFormat {
|
|||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
if (isClosed()) {
|
||||
throw new IllegalStateException("Output is closed");
|
||||
}
|
||||
|
||||
if (index == currentBytes.length) {
|
||||
finishBlock();
|
||||
}
|
||||
|
@ -34,7 +42,15 @@ public class BeaconFormat {
|
|||
index++;
|
||||
}
|
||||
|
||||
private boolean isClosed() {
|
||||
return index == -1;
|
||||
}
|
||||
|
||||
private void finishBlock() throws IOException {
|
||||
if (isClosed()) {
|
||||
throw new IllegalStateException("Output is closed");
|
||||
}
|
||||
|
||||
if (BeaconConfig.printMessages()) {
|
||||
System.out.println("Sending data block of length " + index);
|
||||
}
|
||||
|
|
|
@ -56,6 +56,18 @@ public abstract class ValueNode extends DataStructureNode {
|
|||
return created;
|
||||
}
|
||||
|
||||
public static ValueNode ofText(String text) {
|
||||
var created = of(text);
|
||||
created.tag(IS_TEXT);
|
||||
return created;
|
||||
}
|
||||
|
||||
public static ValueNode ofInteger(int integer) {
|
||||
var created = of(integer);
|
||||
created.tag(IS_INTEGER);
|
||||
return created;
|
||||
}
|
||||
|
||||
public static ValueNode ofInteger(BigInteger integer) {
|
||||
var created = of(integer);
|
||||
created.tag(IS_INTEGER);
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package io.xpipe.core.impl;
|
||||
|
||||
import io.xpipe.core.data.generic.GenericDataStreamParser;
|
||||
import io.xpipe.core.data.node.DataStructureNode;
|
||||
import io.xpipe.core.source.StreamReadConnection;
|
||||
import io.xpipe.core.source.StructureReadConnection;
|
||||
|
||||
public class XpbsReadConnection extends StreamReadConnection implements StructureReadConnection {
|
||||
|
||||
public XpbsReadConnection(XpbsSource source) {
|
||||
super(source.getStore(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataStructureNode read() throws Exception {
|
||||
return GenericDataStreamParser.parse(inputStream);
|
||||
}
|
||||
}
|
|
@ -6,18 +6,20 @@ import io.xpipe.core.source.StructureReadConnection;
|
|||
import io.xpipe.core.source.StructureWriteConnection;
|
||||
import io.xpipe.core.store.StreamDataStore;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import lombok.extern.jackson.Jacksonized;
|
||||
|
||||
@JsonTypeName("xpbs")
|
||||
@SuperBuilder
|
||||
@Jacksonized
|
||||
public class XpbsSource extends StructureDataSource<StreamDataStore> {
|
||||
|
||||
@Override
|
||||
protected StructureWriteConnection newWriteConnection() {
|
||||
return null;
|
||||
return new XpbsWriteConnection(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StructureReadConnection newReadConnection() {
|
||||
return null;
|
||||
return new XpbsReadConnection(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package io.xpipe.core.impl;
|
||||
|
||||
import io.xpipe.core.data.generic.GenericDataStreamWriter;
|
||||
import io.xpipe.core.data.node.DataStructureNode;
|
||||
import io.xpipe.core.source.StreamWriteConnection;
|
||||
import io.xpipe.core.source.StructureWriteConnection;
|
||||
|
||||
public class XpbsWriteConnection extends StreamWriteConnection implements StructureWriteConnection {
|
||||
|
||||
public XpbsWriteConnection(XpbsSource source) {
|
||||
super(source.getStore(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataStructureNode node) throws Exception {
|
||||
GenericDataStreamWriter.writeStructure(outputStream,node);
|
||||
}
|
||||
}
|
|
@ -6,11 +6,15 @@ import io.xpipe.core.source.TableReadConnection;
|
|||
import io.xpipe.core.source.TableWriteConnection;
|
||||
import io.xpipe.core.store.StreamDataStore;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import lombok.extern.jackson.Jacksonized;
|
||||
|
||||
@JsonTypeName("xpbt")
|
||||
@SuperBuilder
|
||||
@Jacksonized
|
||||
public class XpbtSource extends TableDataSource<StreamDataStore> {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected TableWriteConnection newWriteConnection() {
|
||||
return new XpbtWriteConnection(store);
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package io.xpipe.core.store;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import lombok.Getter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import lombok.extern.jackson.Jacksonized;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
|
@ -12,16 +13,13 @@ import java.util.Optional;
|
|||
* The referenced store has to be resolved by the caller manually, as this class does not act as a resolver.
|
||||
*/
|
||||
@JsonTypeName("named")
|
||||
@SuperBuilder
|
||||
@Jacksonized
|
||||
public final class NamedStore implements DataStore {
|
||||
|
||||
@Getter
|
||||
private final String name;
|
||||
|
||||
@JsonCreator
|
||||
public NamedStore(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws Exception {
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
|
@ -3,6 +3,7 @@ package io.xpipe.core.store;
|
|||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import io.xpipe.core.util.JacksonizedValue;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import lombok.extern.jackson.Jacksonized;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -10,6 +11,7 @@ import java.io.OutputStream;
|
|||
|
||||
@JsonTypeName("stdin")
|
||||
@SuperBuilder
|
||||
@Jacksonized
|
||||
public class StdinDataStore extends JacksonizedValue implements StreamDataStore {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,12 +3,14 @@ package io.xpipe.core.store;
|
|||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import io.xpipe.core.util.JacksonizedValue;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import lombok.extern.jackson.Jacksonized;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
@JsonTypeName("stdout")
|
||||
@SuperBuilder
|
||||
@Jacksonized
|
||||
public class StdoutDataStore extends JacksonizedValue implements StreamDataStore {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
package io.xpipe.core.store;
|
||||
|
||||
import lombok.Value;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import lombok.extern.jackson.Jacksonized;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
@Value
|
||||
|
||||
@JsonTypeName("url")
|
||||
@SuperBuilder
|
||||
@Jacksonized
|
||||
public class URLDataStore implements StreamDataStore {
|
||||
|
||||
URL url;
|
||||
private final URL url;
|
||||
|
||||
@Override
|
||||
public InputStream openInput() throws Exception {
|
||||
|
|
|
@ -2,11 +2,7 @@ package io.xpipe.extension.util;
|
|||
|
||||
import io.xpipe.core.dialog.Dialog;
|
||||
import io.xpipe.core.source.DataSource;
|
||||
import io.xpipe.core.store.DataStore;
|
||||
import io.xpipe.extension.DataSourceProvider;
|
||||
import io.xpipe.extension.ExtensionException;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public interface UniformDataSourceProvider<T extends DataSource<?>> extends DataSourceProvider<T> {
|
||||
|
||||
|
@ -15,13 +11,4 @@ public interface UniformDataSourceProvider<T extends DataSource<?>> extends Data
|
|||
return Dialog.empty().evaluateTo(() -> source);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
default T createDefaultSource(DataStore input) throws Exception {
|
||||
try {
|
||||
return (T) getSourceClass().getDeclaredConstructors()[0].newInstance(input);
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
throw new ExtensionException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue