mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-17 17:04:42 -04:00
refactoring of builder classes
This commit is contained in:
parent
7bcd679edf
commit
71b06ad040
@ -1,11 +1,10 @@
|
|||||||
package de.neemann.digital.builder;
|
package de.neemann.digital.builder;
|
||||||
|
|
||||||
import de.neemann.digital.analyse.expression.Expression;
|
import de.neemann.digital.analyse.expression.Expression;
|
||||||
import de.neemann.digital.builder.circuit.CircuitBuilder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface used to create a circuit
|
* Interface used to create a circuit
|
||||||
* There are two implementations: {@link CircuitBuilder} creates a circuit and the
|
* There are two implementations: the {@link de.neemann.digital.builder.circuit.CircuitBuilder} creates a circuit and the
|
||||||
* {@link de.neemann.digital.builder.Gal16v8.Gal16v8CuplExporter} creates a CUPL file
|
* {@link de.neemann.digital.builder.Gal16v8.Gal16v8CuplExporter} creates a CUPL file
|
||||||
* which contains the circuit.
|
* which contains the circuit.
|
||||||
*
|
*
|
||||||
|
@ -29,7 +29,7 @@ import java.util.Map;
|
|||||||
* @author hneemann
|
* @author hneemann
|
||||||
*/
|
*/
|
||||||
public class Gal16v8CuplExporter implements ExpressionExporter<Gal16v8CuplExporter> {
|
public class Gal16v8CuplExporter implements ExpressionExporter<Gal16v8CuplExporter> {
|
||||||
private final DateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yyyy");
|
private final DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
|
||||||
|
|
||||||
private final String projectName;
|
private final String projectName;
|
||||||
private final String username;
|
private final String username;
|
||||||
@ -86,7 +86,7 @@ public class Gal16v8CuplExporter implements ExpressionExporter<Gal16v8CuplExport
|
|||||||
out
|
out
|
||||||
.append("Name ").append(projectName).append(" ;\r\n")
|
.append("Name ").append(projectName).append(" ;\r\n")
|
||||||
.append("PartNo 00 ;\r\n")
|
.append("PartNo 00 ;\r\n")
|
||||||
.append("Date ").append(DATE_FORMAT.format(date)).append(" ;\r\n")
|
.append("Date ").append(dateFormat.format(date)).append(" ;\r\n")
|
||||||
.append("Revision 01 ;\r\n")
|
.append("Revision 01 ;\r\n")
|
||||||
.append("Designer ").append(username).append(" ;\r\n")
|
.append("Designer ").append(username).append(" ;\r\n")
|
||||||
.append("Company unknown ;\r\n")
|
.append("Company unknown ;\r\n")
|
||||||
@ -157,8 +157,8 @@ public class Gal16v8CuplExporter implements ExpressionExporter<Gal16v8CuplExport
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final class NotAllowedVariablesVisitor implements ExpressionVisitor {
|
private static final class NotAllowedVariablesVisitor implements ExpressionVisitor {
|
||||||
|
private static final String NOT_ALLOWED_CHARS = " &#()-+[]/:.*;,!'=@$^\"";
|
||||||
private final HashSet<String> notAllowed;
|
private final HashSet<String> notAllowed;
|
||||||
private final String notAllowedChars = " &#()-+[]/:.*;,!'=@$^\"";
|
|
||||||
|
|
||||||
NotAllowedVariablesVisitor() {
|
NotAllowedVariablesVisitor() {
|
||||||
notAllowed = new HashSet<>();
|
notAllowed = new HashSet<>();
|
||||||
@ -185,8 +185,8 @@ public class Gal16v8CuplExporter implements ExpressionExporter<Gal16v8CuplExport
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void check(String v) {
|
private void check(String v) {
|
||||||
for (int i = 0; i < notAllowedChars.length(); i++)
|
for (int i = 0; i < NOT_ALLOWED_CHARS.length(); i++)
|
||||||
if (v.indexOf(notAllowedChars.charAt(i)) >= 0)
|
if (v.indexOf(NOT_ALLOWED_CHARS.charAt(i)) >= 0)
|
||||||
throw new RuntimeException(Lang.get("err_varNotAllowedInCUPL_N", v));
|
throw new RuntimeException(Lang.get("err_varNotAllowedInCUPL_N", v));
|
||||||
if (notAllowed.contains(v))
|
if (notAllowed.contains(v))
|
||||||
throw new RuntimeException(Lang.get("err_varNotAllowedInCUPL_N", v));
|
throw new RuntimeException(Lang.get("err_varNotAllowedInCUPL_N", v));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user