final version

This commit is contained in:
Michal Pawlaczyk 2020-04-04 23:01:56 +02:00
commit 1b1bb36bbe
45 changed files with 901 additions and 0 deletions

16
.idea/compiler.xml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="Project1Pesel" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="Project1Pesel" target="1.14" />
</bytecodeTargetLevel>
</component>
</project>

1
.idea/description.html Normal file
View File

@ -0,0 +1 @@
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>

6
.idea/encodings.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: junit:junit:4.12">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: log4j:log4j:1.2.17">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/log4j/log4j/1.2.17/log4j-1.2.17.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/log4j/log4j/1.2.17/log4j-1.2.17-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/log4j/log4j/1.2.17/log4j-1.2.17-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.hamcrest:hamcrest-core:1.3">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar!/" />
</SOURCES>
</library>
</component>

16
.idea/misc.xml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectKey">
<option name="state" value="project://e2804f05-5315-4fc6-a121-c522a6c26470" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="false" project-jdk-name="14" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Project1Pesel.iml" filepath="$PROJECT_DIR$/Project1Pesel.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,3 @@
<template>
<input-field default="com.company">IJ_BASE_PACKAGE</input-field>
</template>

124
.idea/uiDesigner.xml Normal file
View File

@ -0,0 +1,124 @@
<?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>

111
.idea/workspace.xml Normal file
View File

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="a81d195f-d729-4df8-820f-1992ec836829" name="Default Changelist" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="MavenImportPreferences">
<option name="importingSettings">
<MavenImportingSettings>
<option name="importAutomatically" value="true" />
</MavenImportingSettings>
</option>
</component>
<component name="ProjectId" id="1ZlAALtM7KdbkkH3CBBNK4VBAxh" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.0" />
</component>
<component name="RunManager">
<configuration name="Main" type="Application" factoryName="Application" temporary="true">
<option name="MAIN_CLASS_NAME" value="com.company.Main" />
<module name="Project1Pesel" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Run" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.Main" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="a81d195f-d729-4df8-820f-1992ec836829" name="Default Changelist" comment="" />
<created>1585403162717</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1585403162717</updated>
</task>
<servers />
</component>
<component name="WindowStateProjectService">
<state x="552" y="213" key="#Intentions" timestamp="1585946678130">
<screen x="0" y="30" width="1920" height="1050" />
</state>
<state x="552" y="213" key="#Intentions/0.1110.1920.1050/0.30.1920.1050@0.30.1920.1050" timestamp="1585946678130" />
<state x="551" y="217" key="#Plugins" timestamp="1585473291168">
<screen x="0" y="30" width="1920" height="1050" />
</state>
<state x="551" y="217" key="#Plugins/0.1110.1920.1050/0.30.1920.1050@0.30.1920.1050" timestamp="1585473291168" />
<state x="552" y="213" key="#Project_Structure" timestamp="1585476973912">
<screen x="0" y="30" width="1920" height="1050" />
</state>
<state x="552" y="213" key="#Project_Structure/0.1110.1920.1050/0.30.1920.1050@0.30.1920.1050" timestamp="1585476973912" />
<state x="683" y="244" key="#com.intellij.ide.util.frameworkSupport.AddFrameworkSupportDialog" timestamp="1585475922927">
<screen x="0" y="30" width="1920" height="1050" />
</state>
<state x="683" y="244" key="#com.intellij.ide.util.frameworkSupport.AddFrameworkSupportDialog/0.1110.1920.1050/0.30.1920.1050@0.30.1920.1050" timestamp="1585475922927" />
<state x="740" y="310" key="FileChooserDialogImpl" timestamp="1585946148289">
<screen x="0" y="30" width="1920" height="1050" />
</state>
<state x="740" y="310" key="FileChooserDialogImpl/0.1110.1920.1050/0.30.1920.1050@0.30.1920.1050" timestamp="1585946148289" />
<state width="1877" height="178" key="GridCell.Tab.0.bottom" timestamp="1585946921870">
<screen x="0" y="30" width="1920" height="1050" />
</state>
<state width="1877" height="178" key="GridCell.Tab.0.bottom/0.1110.1920.1050/0.30.1920.1050@0.30.1920.1050" timestamp="1585946921870" />
<state width="1877" height="178" key="GridCell.Tab.0.center" timestamp="1585946921870">
<screen x="0" y="30" width="1920" height="1050" />
</state>
<state width="1877" height="178" key="GridCell.Tab.0.center/0.1110.1920.1050/0.30.1920.1050@0.30.1920.1050" timestamp="1585946921870" />
<state width="1877" height="178" key="GridCell.Tab.0.left" timestamp="1585946921870">
<screen x="0" y="30" width="1920" height="1050" />
</state>
<state width="1877" height="178" key="GridCell.Tab.0.left/0.1110.1920.1050/0.30.1920.1050@0.30.1920.1050" timestamp="1585946921870" />
<state width="1877" height="178" key="GridCell.Tab.0.right" timestamp="1585946921870">
<screen x="0" y="30" width="1920" height="1050" />
</state>
<state width="1877" height="178" key="GridCell.Tab.0.right/0.1110.1920.1050/0.30.1920.1050@0.30.1920.1050" timestamp="1585946921870" />
<state x="616" y="258" key="run.anything.popup" timestamp="1585564392260">
<screen x="0" y="30" width="1920" height="1050" />
</state>
<state x="616" y="258" key="run.anything.popup/0.1110.1920.1050/0.30.1920.1050@0.30.1920.1050" timestamp="1585564392260" />
<state x="622" y="263" width="672" height="678" key="search.everywhere.popup" timestamp="1585473267671">
<screen x="0" y="30" width="1920" height="1050" />
</state>
<state x="622" y="263" width="672" height="678" key="search.everywhere.popup/0.1110.1920.1050/0.30.1920.1050@0.30.1920.1050" timestamp="1585473267671" />
</component>
</project>

18
Project1Pesel.iml Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_X">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>

23
log.log Normal file
View File

@ -0,0 +1,23 @@
2020-03-29 23:47:31 INFO VerifyPesel:17 - Running the test code in
2020-03-29 23:47:31 INFO VerifyPesel:17 - Running the test code in
2020-03-29 23:48:18 INFO VerifyPesel:17 - Running the test code in
2020-03-29 23:48:18 INFO VerifyPesel:17 - Running the test code in
2020-03-29 23:51:21 INFO VerifyPesel:18 - Running the test code in
2020-03-29 23:51:21 INFO VerifyPesel:18 - Running the test code in
2020-03-29 23:51:21 INFO VerifyPesel:18 - Running the test code in
2020-04-02 21:35:07 INFO AddToFile:19 - Running the test code in AddToFileTest
2020-04-02 21:35:08 INFO VerifyPesel:18 - Running the test code in
2020-04-02 21:35:08 INFO VerifyPesel:18 - Running the test code in
2020-04-02 21:35:08 INFO VerifyPesel:18 - Running the test code in
2020-04-02 22:01:13 INFO AddToFile:19 - Running the test code in AddToFileTest
2020-04-02 22:01:13 INFO VerifyPesel:18 - Running the test code in VerifyPeselTest
2020-04-02 22:01:13 INFO VerifyPesel:18 - Running the test code in VerifyPeselTest
2020-04-02 22:01:13 INFO VerifyPesel:18 - Running the test code in VerifyPeselTest
2020-04-02 22:02:12 INFO AddToFile:19 - Running the test code in AddToFileTest
2020-04-02 22:02:12 INFO VerifyPesel:18 - Running the test code in VerifyPeselTest
2020-04-02 22:02:12 INFO VerifyPesel:18 - Running the test code in VerifyPeselTest
2020-04-02 22:02:12 INFO VerifyPesel:18 - Running the test code in VerifyPeselTest
2020-04-02 22:03:03 INFO AddToFile:19 - Running the test code in AddToFileTest
2020-04-02 22:03:04 INFO VerifyPesel:18 - Running the test code in VerifyPeselTest
2020-04-02 22:03:04 INFO VerifyPesel:18 - Running the test code in VerifyPeselTest
2020-04-02 22:03:04 INFO VerifyPesel:18 - Running the test code in VerifyPeselTest

60
pom.xml Normal file
View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>Project1Pesel</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>14</maven.compiler.source>
<maven.compiler.target>14</maven.compiler.target>
</properties>
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<attach>false</attach>
<appendAssemblyId>false</appendAssemblyId>
<archive>
<manifest>
<mainClass>
second.debug.Breakpoints
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,66 @@
package com.company;
import java.io.File;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class AddToFile {
public static final String xmlFilePath = javax.swing.filechooser.FileSystemView.getFileSystemView().getHomeDirectory() + "\\xmlfile.xml";
public static void addPersonsToFile(ArrayList<Person> persons) {
System.out.println("Saving...");
try {
DocumentBuilderFactory documentFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentFactory.newDocumentBuilder();
Document document = documentBuilder.newDocument();
Element rootElement = document.createElement("persons");
document.appendChild(rootElement);
for (Person person : persons) {
Element employee = document.createElement("person");
rootElement.appendChild(employee);
Element name = document.createElement("name");
name.appendChild(document.createTextNode(person.getName()));
employee.appendChild(name);
Element surname = document.createElement("surname");
surname.appendChild(document.createTextNode(person.getSurname()));
employee.appendChild(surname);
Element city = document.createElement("city");
city.appendChild(document.createTextNode(person.getCity()));
employee.appendChild(city);
Element department = document.createElement("pesel");
department.appendChild(document.createTextNode(person.getPesel()));
employee.appendChild(department);
}
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource domSource = new DOMSource(document);
StreamResult streamResult = new StreamResult(new File(xmlFilePath));
transformer.transform(domSource, streamResult);
System.out.println("Saved");
} catch (ParserConfigurationException | TransformerException pce) {
pce.printStackTrace();
System.out.println("Something goes wrong!");
}
}
}

View File

@ -0,0 +1,8 @@
package com.company;
public class Main {
public static void main(String[] args) {
new ReadParameters().read();
}
}

View File

@ -0,0 +1,31 @@
package com.company;
public class Person {
private final String city;
private final String name;
private final String surname;
private final String pesel;
public Person(String city, String name, String surname, String pesel) {
this.city = city;
this.name = name;
this.surname = surname;
this.pesel = pesel;
}
public String getPesel() {
return pesel;
}
public String getName() {
return name;
}
public String getSurname() {
return surname;
}
public String getCity() {
return city;
}
public String[] getPerson(){
return new String[]{city, name, surname, pesel};
}
}

View File

@ -0,0 +1,75 @@
package com.company;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ReadParameters {
private boolean isInputWordsOnly(String input) {
Pattern wordsOnlyRegex = Pattern.compile("\\^[Aa-zZ]");
Matcher matcher = wordsOnlyRegex.matcher(input);
return matcher.matches();
}
private boolean isInputDigitsOnly(String input) {
Pattern digitsOnlyRegex = Pattern.compile("\\^[0-9]+");
Matcher matcher = digitsOnlyRegex.matcher(input);
return matcher.matches();
}
private Person readOnePerson() {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
System.out.println("City");
String city = reader.readLine();
System.out.println("Name");
String name = reader.readLine();
System.out.println("Surname");
String surname = reader.readLine();
System.out.println("Pesel");
String pesel = reader.readLine();
if (isInputWordsOnly(city) && isInputWordsOnly(name) && isInputWordsOnly(surname) && isInputDigitsOnly(pesel)) {
if (new VerifyPesel(Long.parseLong(pesel)).check()) {
return new Person(city, name, surname, pesel);
}
}
System.out.println("Bad input");
return null;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public void read() {
boolean isNextPersonAdded = true;
ArrayList<Person> allPersons = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while (isNextPersonAdded) {
Person person = readOnePerson();
if (person != null) {
allPersons.removeIf(item -> person.getPesel().equals(item.getPesel()));
allPersons.add(person);
}
String newPerson = "n";
try {
System.out.println("Do you want to add another person ? Y | N");
newPerson = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
}
isNextPersonAdded = newPerson.toLowerCase().equals("y");
}
if(allPersons.size() > 0){
AddToFile.addPersonsToFile(allPersons);
}
}
}

View File

@ -0,0 +1,29 @@
package com.company;
import java.lang.reflect.Array;
public class VerifyPesel {
private final long[] pesel;
public VerifyPesel(long pesel) {
this.pesel = intToArray(pesel);
}
private long[] intToArray(long number) {
int len = Long.toString(number).length();
long[] numberArr = new long[len];
for (int i = 0; number != 0; i++) {
numberArr[len - i - 1] = number % 10;
number = number / 10;
}
return numberArr;
}
public boolean check() {
if (Array.getLength(pesel) == 11) {
long addedPeselNumbers = 9 * pesel[0] + 7 * pesel[1] + 3 * pesel[2] + pesel[3] + 9 * pesel[4] + 7 * pesel[5] + 3 * pesel[6] + pesel[7] + 9 * pesel[8] + 7 * pesel[9];
return addedPeselNumbers % 10 == pesel[10];
}
return false;
}
}

View File

View File

@ -0,0 +1,16 @@
# Root logger option
log4j.rootLogger=DEBUG, stdout, file
# Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=log.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

View File

@ -0,0 +1,47 @@
package junit;
import com.company.AddToFile;
import com.company.Person;
import org.apache.log4j.Logger;
import org.junit.Before;
import org.junit.Test;
import java.io.*;
import java.util.ArrayList;
import static org.junit.Assert.*;
public class AddToFileTest {
final static Logger logger = Logger.getLogger(AddToFile.class);
@Before
public void setUp() {
logger.info("Running the test code in AddToFileTest");
}
@Test
public void correctValueTest() throws IOException {
String exampleXML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><persons><person><name>Jan</name><surname>Kowalski</surname><city>Poznan</city><pesel>91120691355</pesel></person><person><name>Maciej</name><surname>Nowak</surname><city>Warszawa</city><pesel>74121719679</pesel></person><person><name>Adam</name><surname>Kowalski</surname><city>Krakow</city><pesel>54081855266</pesel></person></persons>";
ArrayList<Person> allPersons = new ArrayList<>();
allPersons.add(new Person("Poznan", "Jan", "Kowalski", "91120691355"));
allPersons.add(new Person("Warszawa", "Maciej", "Nowak", "74121719679"));
allPersons.add(new Person("Krakow", "Adam", "Kowalski", "54081855266"));
AddToFile.addPersonsToFile(allPersons);
InputStream is = new FileInputStream(AddToFile.xmlFilePath);
BufferedReader buf = new BufferedReader(new InputStreamReader(is));
String line = buf.readLine();
StringBuilder sb = new StringBuilder();
while(line != null){
sb.append(line);
line = buf.readLine();
}
String fileAsString = sb.toString();
assertEquals(exampleXML, fileAsString);
}
}

View File

@ -0,0 +1,36 @@
package junit;
import com.company.VerifyPesel;
import org.apache.log4j.Logger;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class VerifyPeselTest {
final static Logger logger = Logger.getLogger(VerifyPesel.class);
final static long correctPesel = 91120691355L;
final static long tooShortPesel = 97081802L;
final static long tooLongPesel = 9112069135523L;
@Before
public void setUp() {
logger.info("Running the test code in VerifyPeselTest");
}
@Test
public void correctValueTest() {
assertTrue(new VerifyPesel(correctPesel).check());
}
@Test
public void tooShortValueTest() {
assertFalse(new VerifyPesel(tooShortPesel).check());
}
@Test
public void stringValueTest() {
assertFalse(new VerifyPesel(tooLongPesel).check());
}
}

Binary file not shown.

Binary file not shown.

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,16 @@
# Root logger option
log4j.rootLogger=DEBUG, stdout, file
# Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=log.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

View File

@ -0,0 +1,5 @@
#Generated by Maven
#Sun Mar 29 12:21:25 CEST 2020
groupId=groupId
artifactId=Project1Pesel
version=1.0-SNAPSHOT

View File

@ -0,0 +1,4 @@
com\company\AddToFile.class
com\company\Main.class
com\company\VerifyPesel.class
com\company\ReadParameters.class

View File

@ -0,0 +1,5 @@
C:\Users\micha\dev\Studia\Java_JSON_XML\Project1Pesel\src\main\java\com\company\ReadParameters.java
C:\Users\micha\dev\Studia\Java_JSON_XML\Project1Pesel\src\main\java\com\company\Main.java
C:\Users\micha\dev\Studia\Java_JSON_XML\Project1Pesel\src\main\java\com\company\Person.java
C:\Users\micha\dev\Studia\Java_JSON_XML\Project1Pesel\src\main\java\com\company\VerifyPesel.java
C:\Users\micha\dev\Studia\Java_JSON_XML\Project1Pesel\src\main\java\com\company\AddToFile.java

View File

@ -0,0 +1,2 @@
C:\Users\micha\dev\Studia\Java_JSON_XML\Project1Pesel\src\test\java\junit\AddToFileTest.java
C:\Users\micha\dev\Studia\Java_JSON_XML\Project1Pesel\src\test\java\junit\VerifyPeselTest.java

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite tests="1" failures="0" name="junit.AddToFileTest" time="0.308" errors="0" skipped="0">
<properties>
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
<property name="java.vm.version" value="14+36-1461"/>
<property name="sun.boot.library.path" value="C:\Program Files\OpenJDK\jdk-14\bin"/>
<property name="maven.multiModuleProjectDirectory" value="C:\Users\micha\dev\Studia\Java_JSON_XML\Project1Pesel"/>
<property name="java.vm.vendor" value="Oracle Corporation"/>
<property name="java.vendor.url" value="https://java.oracle.com/"/>
<property name="guice.disable.misplaced.annotation.check" value="true"/>
<property name="path.separator" value=";"/>
<property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/>
<property name="sun.os.patch.level" value=""/>
<property name="user.script" value=""/>
<property name="user.country" value="PL"/>
<property name="sun.java.launcher" value="SUN_STANDARD"/>
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
<property name="user.dir" value="C:\Users\micha\dev\Studia\Java_JSON_XML\Project1Pesel"/>
<property name="java.vm.compressedOopsMode" value="Zero based"/>
<property name="java.runtime.version" value="14+36-1461"/>
<property name="os.arch" value="amd64"/>
<property name="java.io.tmpdir" value="C:\Users\micha\AppData\Local\Temp\"/>
<property name="line.separator" value="
"/>
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
<property name="user.variant" value=""/>
<property name="os.name" value="Windows 10"/>
<property name="maven.ext.class.path" value="C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.4\plugins\maven\lib\maven-event-listener.jar"/>
<property name="classworlds.conf" value="C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.4\plugins\maven\lib\maven3\bin\m2.conf"/>
<property name="sun.jnu.encoding" value="Cp1250"/>
<property name="java.library.path" value="C:\Program Files\OpenJDK\jdk-14\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Python27\;C:\Python27\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Lenovo\Bluetooth Software\;C:\Program Files\Lenovo\Bluetooth Software\syswow64;C:\ProgramData\chocolatey\bin;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\OpenJDK\jdk-14\bin;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Program Files\Java\jdk1.8.0_211\bin;C:\Android\tools\bin\platform-tools;C:\Users\micha\AppData\Local\Microsoft\WindowsApps;C:\Users\micha\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\micha\AppData\Local\hyper\app-3.0.2\resources\bin;C:\Users\micha\AppData\Roaming\npm;C:\Users\micha\AppData\Local\GitHubDesktop\bin;."/>
<property name="maven.conf" value="C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.4\plugins\maven\lib\maven3/conf"/>
<property name="jdk.debug" value="release"/>
<property name="java.class.version" value="58.0"/>
<property name="java.specification.name" value="Java Platform API Specification"/>
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
<property name="idea.version2019.3.4" value="true"/>
<property name="os.version" value="10.0"/>
<property name="user.home" value="C:\Users\micha"/>
<property name="user.timezone" value="Europe/Warsaw"/>
<property name="file.encoding" value="UTF-8"/>
<property name="java.specification.version" value="14"/>
<property name="user.name" value="micha"/>
<property name="java.class.path" value="C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.4\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar"/>
<property name="java.vm.specification.version" value="14"/>
<property name="sun.arch.data.model" value="64"/>
<property name="sun.java.command" value="org.codehaus.classworlds.Launcher -Didea.version2019.3.4 test"/>
<property name="java.home" value="C:\Program Files\OpenJDK\jdk-14"/>
<property name="user.language" value="pl"/>
<property name="java.specification.vendor" value="Oracle Corporation"/>
<property name="java.vm.info" value="mixed mode, sharing"/>
<property name="java.version" value="14"/>
<property name="java.vendor" value="Oracle Corporation"/>
<property name="maven.home" value="C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.4\plugins\maven\lib\maven3"/>
<property name="file.separator" value="\"/>
<property name="java.version.date" value="2020-03-17"/>
<property name="java.vendor.url.bug" value="https://bugreport.java.com/bugreport/"/>
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
<property name="sun.cpu.endian" value="little"/>
<property name="sun.cpu.isalist" value="amd64"/>
</properties>
<testcase classname="junit.AddToFileTest" name="correctValueTest" time="0.308"/>
</testsuite>

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite tests="3" failures="0" name="junit.VerifyPeselTest" time="0.001" errors="0" skipped="0">
<properties>
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
<property name="java.vm.version" value="14+36-1461"/>
<property name="sun.boot.library.path" value="C:\Program Files\OpenJDK\jdk-14\bin"/>
<property name="maven.multiModuleProjectDirectory" value="C:\Users\micha\dev\Studia\Java_JSON_XML\Project1Pesel"/>
<property name="java.vm.vendor" value="Oracle Corporation"/>
<property name="java.vendor.url" value="https://java.oracle.com/"/>
<property name="guice.disable.misplaced.annotation.check" value="true"/>
<property name="path.separator" value=";"/>
<property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/>
<property name="sun.os.patch.level" value=""/>
<property name="user.script" value=""/>
<property name="user.country" value="PL"/>
<property name="sun.java.launcher" value="SUN_STANDARD"/>
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
<property name="user.dir" value="C:\Users\micha\dev\Studia\Java_JSON_XML\Project1Pesel"/>
<property name="java.vm.compressedOopsMode" value="Zero based"/>
<property name="java.runtime.version" value="14+36-1461"/>
<property name="os.arch" value="amd64"/>
<property name="java.io.tmpdir" value="C:\Users\micha\AppData\Local\Temp\"/>
<property name="line.separator" value="
"/>
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
<property name="user.variant" value=""/>
<property name="os.name" value="Windows 10"/>
<property name="maven.ext.class.path" value="C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.4\plugins\maven\lib\maven-event-listener.jar"/>
<property name="classworlds.conf" value="C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.4\plugins\maven\lib\maven3\bin\m2.conf"/>
<property name="sun.jnu.encoding" value="Cp1250"/>
<property name="java.library.path" value="C:\Program Files\OpenJDK\jdk-14\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Python27\;C:\Python27\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Lenovo\Bluetooth Software\;C:\Program Files\Lenovo\Bluetooth Software\syswow64;C:\ProgramData\chocolatey\bin;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\OpenJDK\jdk-14\bin;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Program Files\Java\jdk1.8.0_211\bin;C:\Android\tools\bin\platform-tools;C:\Users\micha\AppData\Local\Microsoft\WindowsApps;C:\Users\micha\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\micha\AppData\Local\hyper\app-3.0.2\resources\bin;C:\Users\micha\AppData\Roaming\npm;C:\Users\micha\AppData\Local\GitHubDesktop\bin;."/>
<property name="maven.conf" value="C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.4\plugins\maven\lib\maven3/conf"/>
<property name="jdk.debug" value="release"/>
<property name="java.class.version" value="58.0"/>
<property name="java.specification.name" value="Java Platform API Specification"/>
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
<property name="idea.version2019.3.4" value="true"/>
<property name="os.version" value="10.0"/>
<property name="user.home" value="C:\Users\micha"/>
<property name="user.timezone" value="Europe/Warsaw"/>
<property name="file.encoding" value="UTF-8"/>
<property name="java.specification.version" value="14"/>
<property name="user.name" value="micha"/>
<property name="java.class.path" value="C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.4\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar"/>
<property name="java.vm.specification.version" value="14"/>
<property name="sun.arch.data.model" value="64"/>
<property name="sun.java.command" value="org.codehaus.classworlds.Launcher -Didea.version2019.3.4 test"/>
<property name="java.home" value="C:\Program Files\OpenJDK\jdk-14"/>
<property name="user.language" value="pl"/>
<property name="java.specification.vendor" value="Oracle Corporation"/>
<property name="java.vm.info" value="mixed mode, sharing"/>
<property name="java.version" value="14"/>
<property name="java.vendor" value="Oracle Corporation"/>
<property name="maven.home" value="C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.4\plugins\maven\lib\maven3"/>
<property name="file.separator" value="\"/>
<property name="java.version.date" value="2020-03-17"/>
<property name="java.vendor.url.bug" value="https://bugreport.java.com/bugreport/"/>
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
<property name="sun.cpu.endian" value="little"/>
<property name="sun.cpu.isalist" value="amd64"/>
</properties>
<testcase classname="junit.VerifyPeselTest" name="correctValueTest" time="0"/>
<testcase classname="junit.VerifyPeselTest" name="stringValueTest" time="0"/>
<testcase classname="junit.VerifyPeselTest" name="tooShortValueTest" time="0.001"/>
</testsuite>

View File

@ -0,0 +1,4 @@
-------------------------------------------------------------------------------
Test set: junit.AddToFileTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.515 sec

View File

@ -0,0 +1,4 @@
-------------------------------------------------------------------------------
Test set: junit.VerifyPeselTest
-------------------------------------------------------------------------------
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 sec

Binary file not shown.

Binary file not shown.