refactoring
This commit is contained in:
parent
a5e80d05ba
commit
256738680f
|
@ -0,0 +1,14 @@
|
||||||
|
package com.rusefi.output;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public abstract class AbstractConfigurationConsumer implements ConfigurationConsumer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startFile() throws IOException {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endFile() throws IOException {
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ import com.rusefi.*;
|
||||||
|
|
||||||
import static com.rusefi.ToolUtil.EOL;
|
import static com.rusefi.ToolUtil.EOL;
|
||||||
|
|
||||||
public abstract class BaseCHeaderConsumer implements ConfigurationConsumer {
|
public abstract class BaseCHeaderConsumer extends AbstractConfigurationConsumer {
|
||||||
private static final String BOOLEAN_TYPE = "bool";
|
private static final String BOOLEAN_TYPE = "bool";
|
||||||
private final StringBuilder content = new StringBuilder();
|
private final StringBuilder content = new StringBuilder();
|
||||||
|
|
||||||
|
@ -63,8 +63,4 @@ public abstract class BaseCHeaderConsumer implements ConfigurationConsumer {
|
||||||
public StringBuilder getContent() {
|
public StringBuilder getContent() {
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startFile() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import java.util.TreeSet;
|
||||||
import static com.rusefi.ConfigField.unquote;
|
import static com.rusefi.ConfigField.unquote;
|
||||||
import static org.abego.treelayout.internal.util.java.lang.string.StringUtil.quote;
|
import static org.abego.treelayout.internal.util.java.lang.string.StringUtil.quote;
|
||||||
|
|
||||||
public class DataLogConsumer implements ConfigurationConsumer {
|
public class DataLogConsumer extends AbstractConfigurationConsumer {
|
||||||
private final String fileName;
|
private final String fileName;
|
||||||
private final ReaderState state;
|
private final ReaderState state;
|
||||||
private final CharArrayWriter tsWriter = new CharArrayWriter();
|
private final CharArrayWriter tsWriter = new CharArrayWriter();
|
||||||
|
@ -25,18 +25,6 @@ public class DataLogConsumer implements ConfigurationConsumer {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startFile() throws IOException {
|
|
||||||
System.out.println("startFile");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void endFile() throws IOException {
|
|
||||||
System.out.println("endFile");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleEndStruct(ConfigStructure structure) throws IOException {
|
public void handleEndStruct(ConfigStructure structure) throws IOException {
|
||||||
if (state.stack.isEmpty()) {
|
if (state.stack.isEmpty()) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import java.io.IOException;
|
||||||
import static com.rusefi.output.DataLogConsumer.getComment;
|
import static com.rusefi.output.DataLogConsumer.getComment;
|
||||||
import static org.abego.treelayout.internal.util.java.lang.string.StringUtil.quote;
|
import static org.abego.treelayout.internal.util.java.lang.string.StringUtil.quote;
|
||||||
|
|
||||||
public class GaugeConsumer implements ConfigurationConsumer {
|
public class GaugeConsumer extends AbstractConfigurationConsumer {
|
||||||
private final String fileName;
|
private final String fileName;
|
||||||
private final ReaderState state;
|
private final ReaderState state;
|
||||||
private final CharArrayWriter charArrayWriter = new CharArrayWriter();
|
private final CharArrayWriter charArrayWriter = new CharArrayWriter();
|
||||||
|
@ -20,18 +20,6 @@ public class GaugeConsumer implements ConfigurationConsumer {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startFile() throws IOException {
|
|
||||||
System.out.println("startFile");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void endFile() throws IOException {
|
|
||||||
System.out.println("endFile");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleEndStruct(ConfigStructure structure) throws IOException {
|
public void handleEndStruct(ConfigStructure structure) throws IOException {
|
||||||
if (state.stack.isEmpty()) {
|
if (state.stack.isEmpty()) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.rusefi.ReaderState;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
public class OutputsSectionConsumer implements ConfigurationConsumer {
|
public class OutputsSectionConsumer extends AbstractConfigurationConsumer {
|
||||||
private final String tsOutputsSectionFileName;
|
private final String tsOutputsSectionFileName;
|
||||||
private final TsOutput tsOutput;
|
private final TsOutput tsOutput;
|
||||||
private final ReaderState state;
|
private final ReaderState state;
|
||||||
|
@ -16,18 +16,10 @@ public class OutputsSectionConsumer implements ConfigurationConsumer {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startFile() throws IOException {
|
|
||||||
}
|
|
||||||
|
|
||||||
public CharArrayWriter getTsWriter() {
|
public CharArrayWriter getTsWriter() {
|
||||||
return tsWriter;
|
return tsWriter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void endFile() throws IOException {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleEndStruct(ConfigStructure structure) throws IOException {
|
public void handleEndStruct(ConfigStructure structure) throws IOException {
|
||||||
System.out.println("handleEndStruct");
|
System.out.println("handleEndStruct");
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.io.IOException;
|
||||||
/**
|
/**
|
||||||
* Configuration consumer which writes Signature header file
|
* Configuration consumer which writes Signature header file
|
||||||
*/
|
*/
|
||||||
public class SignatureConsumer implements ConfigurationConsumer {
|
public class SignatureConsumer extends AbstractConfigurationConsumer {
|
||||||
private final String destHeader;
|
private final String destHeader;
|
||||||
VariableRegistry registry;
|
VariableRegistry registry;
|
||||||
|
|
||||||
|
@ -18,16 +18,8 @@ public class SignatureConsumer implements ConfigurationConsumer {
|
||||||
this.registry = vregistry;
|
this.registry = vregistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startFile() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleEndStruct(ConfigStructure structure) throws IOException {
|
public void handleEndStruct(ConfigStructure structure) throws IOException {
|
||||||
ConfigDefinition.writeDefinesToFile(registry, destHeader);
|
ConfigDefinition.writeDefinesToFile(registry, destHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void endFile() throws IOException {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue