This commit is contained in:
parent
f6fc6521f0
commit
b7d59de955
|
@ -1 +0,0 @@
|
||||||
net_list_merge
|
|
|
@ -1,23 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="CompilerConfiguration">
|
|
||||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
|
||||||
<resourceExtensions />
|
|
||||||
<wildcardResourcePatterns>
|
|
||||||
<entry name="!?*.java" />
|
|
||||||
<entry name="!?*.form" />
|
|
||||||
<entry name="!?*.class" />
|
|
||||||
<entry name="!?*.groovy" />
|
|
||||||
<entry name="!?*.scala" />
|
|
||||||
<entry name="!?*.flex" />
|
|
||||||
<entry name="!?*.kt" />
|
|
||||||
<entry name="!?*.clj" />
|
|
||||||
</wildcardResourcePatterns>
|
|
||||||
<annotationProcessing>
|
|
||||||
<profile default="true" name="Default" enabled="false">
|
|
||||||
<processorPath useClasspath="true" />
|
|
||||||
</profile>
|
|
||||||
</annotationProcessing>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
<component name="CopyrightManager">
|
|
||||||
<settings default="">
|
|
||||||
<module2copyright />
|
|
||||||
</settings>
|
|
||||||
</component>
|
|
|
@ -1,5 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
|
|
||||||
</project>
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="EntryPointsManager">
|
|
||||||
<entry_points version="2.0" />
|
|
||||||
</component>
|
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
|
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
|
||||||
</component>
|
|
||||||
<component name="SvnBranchConfigurationManager">
|
|
||||||
<option name="mySupportsUserInfoFilter" value="true" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/net_list_merge.iml" filepath="$PROJECT_DIR$/net_list_merge.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
<component name="DependencyValidationManager">
|
|
||||||
<state>
|
|
||||||
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
|
|
||||||
</state>
|
|
||||||
</component>
|
|
|
@ -1,125 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Palette2">
|
|
||||||
<group name="Swing">
|
|
||||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="Button" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="RadioButton" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="CheckBox" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="Label" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
|
||||||
<preferred-size width="150" height="-1" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
|
||||||
<preferred-size width="150" height="-1" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
|
||||||
<preferred-size width="150" height="-1" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
|
||||||
<preferred-size width="200" height="200" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
|
||||||
<preferred-size width="200" height="200" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
|
||||||
<preferred-size width="-1" height="20" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
|
||||||
</item>
|
|
||||||
</group>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="" vcs="svn" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
<project default="jar">
|
|
||||||
|
|
||||||
<target name="clean">
|
|
||||||
<delete dir="build"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="compile">
|
|
||||||
<mkdir dir="build/classes"/>
|
|
||||||
<javac destdir="build/classes" classpath="lib/junit.jar:lib/annotations.jar">
|
|
||||||
<src path="src"/>
|
|
||||||
</javac>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="jar" depends="compile">
|
|
||||||
<mkdir dir="build/jar"/>
|
|
||||||
<jar destfile="../net_list_merge.jar" basedir="build/classes">
|
|
||||||
<manifest>
|
|
||||||
<attribute name="Main-Class" value="rusefi.NetListMerge"/>
|
|
||||||
</manifest>
|
|
||||||
<zipfileset dir="build/classes" includes="**/*.class"/>
|
|
||||||
</jar>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="JAVA_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
||||||
|
|
|
@ -1,123 +0,0 @@
|
||||||
package rusefi;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import static rusefi.NetListMergeUtil.validateSection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 12/8/13
|
|
||||||
* (c) Andrey Belomutskiy
|
|
||||||
*/
|
|
||||||
public class NetListMerge {
|
|
||||||
private static final Pattern GET_HEADER = Pattern.compile("(.*)\\(components(.*)\\s*$", Pattern.DOTALL);
|
|
||||||
|
|
||||||
private static final Pattern GET_COMPONENTS = Pattern.compile("(.*)\\)\\s*\\(libparts(.*)\\)\\)\\s*$", Pattern.DOTALL);
|
|
||||||
|
|
||||||
private static final Pattern GET_LIBRARTS = Pattern.compile("(.*)\\)\\s*\\(libraries(.*)", Pattern.DOTALL);
|
|
||||||
private static final Pattern GET_LIBRARIES = Pattern.compile("(.*)\\)\\s*\\(nets(.*)", Pattern.DOTALL);
|
|
||||||
|
|
||||||
|
|
||||||
private NetListMerge() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
|
||||||
if (args.length < 2) {
|
|
||||||
System.out.println("This tool takes 'components' sections of multiple KiCad .net files and merges them into one");
|
|
||||||
System.out.println("usage:");
|
|
||||||
System.out.println("NetListMerge DEST_FILE SOURCE_1 SOURCE_2 [SOURCE_x]*");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String destinationFile = args[0];
|
|
||||||
NetContent destination = parse(NetListMergeUtil.readFile(destinationFile));
|
|
||||||
|
|
||||||
StringBuilder components = new StringBuilder();
|
|
||||||
StringBuilder libparts = new StringBuilder();
|
|
||||||
StringBuilder libraries = new StringBuilder();
|
|
||||||
StringBuilder nets = new StringBuilder();
|
|
||||||
for (int i = 1; i < args.length; i++) {
|
|
||||||
String sourceFile = args[i];
|
|
||||||
NetContent source = parse(NetListMergeUtil.readFile(sourceFile));
|
|
||||||
components.append(source.components);
|
|
||||||
libparts.append(source.libparts);
|
|
||||||
libraries.append(source.libraries);
|
|
||||||
nets.append(source.nets);
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("Total " + components.length() + " bytes of components");
|
|
||||||
System.out.println("Total " + libparts.length() + " bytes of libparts");
|
|
||||||
System.out.println("Total " + libraries.length() + " bytes of libraries");
|
|
||||||
System.out.println("Total " + nets.length() + " bytes of nets");
|
|
||||||
|
|
||||||
StringBuilder result = new StringBuilder(destination.header);
|
|
||||||
result.append(" (components").append(components).append(")\r\n");
|
|
||||||
result.append(" (libparts").append(libparts).append(")\n");
|
|
||||||
result.append(" (libraries").append(libraries).append(")\n");
|
|
||||||
result.append(" (nets").append(nets).append(")");
|
|
||||||
result.append(")");
|
|
||||||
validateSection(result.toString());
|
|
||||||
NetListMergeUtil.writeResult(result.toString(), "out.txt");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class NetContent {
|
|
||||||
private final String header;
|
|
||||||
private final String components;
|
|
||||||
private final String libparts;
|
|
||||||
private final String nets;
|
|
||||||
private final String libraries;
|
|
||||||
|
|
||||||
private NetContent(String header, String components, String libparts, String libraries, String nets) {
|
|
||||||
this.header = header;
|
|
||||||
this.components = components;
|
|
||||||
this.libparts = libparts;
|
|
||||||
this.nets = nets;
|
|
||||||
this.libraries = libraries;
|
|
||||||
System.out.println("Got " + components.length() + " bytes of components");
|
|
||||||
System.out.println("Got " + libparts.length() + " bytes of libparts");
|
|
||||||
System.out.println("Got " + libraries.length() + " bytes of libraries");
|
|
||||||
System.out.println("Got " + nets.length() + " bytes of nets");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static NetContent parse(String content) {
|
|
||||||
Matcher headerMatcher = GET_HEADER.matcher(content);
|
|
||||||
headerMatcher.find();
|
|
||||||
if (!headerMatcher.matches())
|
|
||||||
throw new IllegalStateException("Does not match expected patten for header");
|
|
||||||
|
|
||||||
String header = headerMatcher.group(1);
|
|
||||||
String nonHeader = headerMatcher.group(2);
|
|
||||||
|
|
||||||
Matcher componentsMatcher = GET_COMPONENTS.matcher(nonHeader);
|
|
||||||
if (!componentsMatcher.matches())
|
|
||||||
throw new IllegalStateException("Does not match expected patten for components");
|
|
||||||
|
|
||||||
String components = componentsMatcher.group(1);
|
|
||||||
String nonComponents = componentsMatcher.group(2);
|
|
||||||
validateSection(components);
|
|
||||||
|
|
||||||
Matcher libpartsMatcher = GET_LIBRARTS.matcher(nonComponents);
|
|
||||||
if (!libpartsMatcher.matches())
|
|
||||||
throw new IllegalStateException("Does not match expected patten for libparts");
|
|
||||||
|
|
||||||
String libparts = libpartsMatcher.group(1);
|
|
||||||
String nonlibparts = libpartsMatcher.group(2);
|
|
||||||
validateSection(libparts);
|
|
||||||
|
|
||||||
Matcher librariesMatcher = GET_LIBRARIES.matcher(nonlibparts);
|
|
||||||
if (!librariesMatcher.matches())
|
|
||||||
throw new IllegalStateException("Does not match expected patten for nets");
|
|
||||||
|
|
||||||
String libraries = librariesMatcher.group(1);
|
|
||||||
String nets = librariesMatcher.group(2);
|
|
||||||
validateSection(libraries);
|
|
||||||
validateSection(nets);
|
|
||||||
|
|
||||||
// System.out.println("components: " + components);
|
|
||||||
|
|
||||||
return new NetContent(header, components, libparts, libraries, nets);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
package rusefi;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 12/8/13
|
|
||||||
* (c) Andrey Belomutskiy
|
|
||||||
*/
|
|
||||||
public class NetListMergeUtil {
|
|
||||||
static void writeResult(String content, String fileName) throws IOException {
|
|
||||||
System.out.println("Writing result into " + fileName);
|
|
||||||
BufferedWriter bw = new BufferedWriter(new FileWriter(fileName));
|
|
||||||
bw.write(content);
|
|
||||||
bw.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
static String readFile(String fileName) throws IOException {
|
|
||||||
checkExistence(fileName);
|
|
||||||
|
|
||||||
System.out.println("Reading " + fileName);
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
String line;
|
|
||||||
BufferedReader br = new BufferedReader(new FileReader(fileName));
|
|
||||||
|
|
||||||
while (((line = br.readLine()) != null))
|
|
||||||
sb.append(line).append("\r\n");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void checkExistence(String fileName) {
|
|
||||||
if (!new File(fileName).isFile()) {
|
|
||||||
System.err.println("File not found: " + fileName);
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void validateSection(String section) {
|
|
||||||
int counter = 0;
|
|
||||||
for (int i = 0; i < section.length(); i++) {
|
|
||||||
char c = section.charAt(i);
|
|
||||||
if (c == '(')
|
|
||||||
counter++;
|
|
||||||
else if (c == ')')
|
|
||||||
counter--;
|
|
||||||
if (counter < 0)
|
|
||||||
throw new IllegalStateException("Invalid section: " + section);
|
|
||||||
}
|
|
||||||
if (counter != 0)
|
|
||||||
throw new IllegalStateException("Invalid section: " + section + " balance: " + counter);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue