@ -0,0 +1,6 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="CompilerConfiguration"> | |||
<bytecodeTargetLevel target="11" /> | |||
</component> | |||
</project> |
@ -0,0 +1,17 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="GradleMigrationSettings" migrationVersion="1" /> | |||
<component name="GradleSettings"> | |||
<option name="linkedExternalProjectsSettings"> | |||
<GradleProjectSettings> | |||
<option name="distributionType" value="DEFAULT_WRAPPED" /> | |||
<option name="externalProjectPath" value="$PROJECT_DIR$" /> | |||
<option name="modules"> | |||
<set> | |||
<option value="$PROJECT_DIR$" /> | |||
</set> | |||
</option> | |||
</GradleProjectSettings> | |||
</option> | |||
</component> | |||
</project> |
@ -0,0 +1,20 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="RemoteRepositoriesConfiguration"> | |||
<remote-repository> | |||
<option name="id" value="central" /> | |||
<option name="name" value="Maven Central repository" /> | |||
<option name="url" value="https://repo1.maven.org/maven2" /> | |||
</remote-repository> | |||
<remote-repository> | |||
<option name="id" value="jboss.community" /> | |||
<option name="name" value="JBoss Community repository" /> | |||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" /> | |||
</remote-repository> | |||
<remote-repository> | |||
<option name="id" value="MavenRepo" /> | |||
<option name="name" value="MavenRepo" /> | |||
<option name="url" value="https://repo.maven.apache.org/maven2/" /> | |||
</remote-repository> | |||
</component> | |||
</project> |
@ -0,0 +1,10 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="ExternalStorageConfigurationManager" enabled="true" /> | |||
<component name="FrameworkDetectionExcludesConfiguration"> | |||
<file type="web" url="file://$PROJECT_DIR$" /> | |||
</component> | |||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="corretto-11" project-jdk-type="JavaSDK"> | |||
<output url="file://$PROJECT_DIR$/out" /> | |||
</component> | |||
</project> |
@ -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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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> |
@ -0,0 +1,6 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="VcsDirectoryMappings"> | |||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" /> | |||
</component> | |||
</project> |
@ -0,0 +1,5 @@ | |||
distributionBase=GRADLE_USER_HOME | |||
distributionPath=wrapper/dists | |||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip | |||
zipStoreBase=GRADLE_USER_HOME | |||
zipStorePath=wrapper/dists |
@ -0,0 +1,89 @@ | |||
@rem | |||
@rem Copyright 2015 the original author or authors. | |||
@rem | |||
@rem Licensed under the Apache License, Version 2.0 (the "License"); | |||
@rem you may not use this file except in compliance with the License. | |||
@rem You may obtain a copy of the License at | |||
@rem | |||
@rem https://www.apache.org/licenses/LICENSE-2.0 | |||
@rem | |||
@rem Unless required by applicable law or agreed to in writing, software | |||
@rem distributed under the License is distributed on an "AS IS" BASIS, | |||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
@rem See the License for the specific language governing permissions and | |||
@rem limitations under the License. | |||
@rem | |||
@if "%DEBUG%" == "" @echo off | |||
@rem ########################################################################## | |||
@rem | |||
@rem Gradle startup script for Windows | |||
@rem | |||
@rem ########################################################################## | |||
@rem Set local scope for the variables with windows NT shell | |||
if "%OS%"=="Windows_NT" setlocal | |||
set DIRNAME=%~dp0 | |||
if "%DIRNAME%" == "" set DIRNAME=. | |||
set APP_BASE_NAME=%~n0 | |||
set APP_HOME=%DIRNAME% | |||
@rem Resolve any "." and ".." in APP_HOME to make it shorter. | |||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi | |||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | |||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" | |||
@rem Find java.exe | |||
if defined JAVA_HOME goto findJavaFromJavaHome | |||
set JAVA_EXE=java.exe | |||
%JAVA_EXE% -version >NUL 2>&1 | |||
if "%ERRORLEVEL%" == "0" goto execute | |||
echo. | |||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | |||
echo. | |||
echo Please set the JAVA_HOME variable in your environment to match the | |||
echo location of your Java installation. | |||
goto fail | |||
:findJavaFromJavaHome | |||
set JAVA_HOME=%JAVA_HOME:"=% | |||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe | |||
if exist "%JAVA_EXE%" goto execute | |||
echo. | |||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% | |||
echo. | |||
echo Please set the JAVA_HOME variable in your environment to match the | |||
echo location of your Java installation. | |||
goto fail | |||
:execute | |||
@rem Setup the command line | |||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar | |||
@rem Execute Gradle | |||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* | |||
:end | |||
@rem End local scope for the variables with windows NT shell | |||
if "%ERRORLEVEL%"=="0" goto mainEnd | |||
:fail | |||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of | |||
rem the _cmd.exe /c_ return code! | |||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 | |||
exit /b 1 | |||
:mainEnd | |||
if "%OS%"=="Windows_NT" endlocal | |||
:omega |
@ -0,0 +1,2 @@ | |||
rootProject.name = 'XMLParser' | |||
@ -0,0 +1,31 @@ | |||
package com.antoniofrische; | |||
public class Empleado { | |||
private final String id; | |||
private final String apellido; | |||
private final String departemento; | |||
private final String salario; | |||
public Empleado(String id, String apellido, String departemento, String salario) { | |||
this.id = id; | |||
this.apellido = apellido; | |||
this.departemento = departemento; | |||
this.salario = salario; | |||
} | |||
public String getId() { | |||
return id; | |||
} | |||
public String getApellido() { | |||
return apellido; | |||
} | |||
public String getDepartemento() { | |||
return departemento; | |||
} | |||
public String getSalario() { | |||
return salario; | |||
} | |||
} |
@ -0,0 +1,13 @@ | |||
package com.antoniofrische; | |||
import com.antoniofrische.parser.Parser; | |||
public class MainXMLParser { | |||
public static void main(String[] args) { | |||
Parser parser = new Parser(); | |||
Empleado[] empleados = parser.getEmpleados(); | |||
for (Empleado e: empleados) { | |||
System.out.printf("ID:%s ;Nombre:%s ;Departamento:%s ;Salario:%s€ \n", e.getId(),e.getApellido(), e.getDepartemento(), e.getSalario()); | |||
} | |||
} | |||
} |
@ -0,0 +1,47 @@ | |||
package com.antoniofrische.parser; | |||
import com.antoniofrische.Empleado; | |||
import org.w3c.dom.Document; | |||
import org.w3c.dom.Element; | |||
import org.w3c.dom.Node; | |||
import org.w3c.dom.NodeList; | |||
import javax.xml.parsers.DocumentBuilder; | |||
import javax.xml.parsers.DocumentBuilderFactory; | |||
import java.io.File; | |||
public class Parser { | |||
Empleado[] empleados; | |||
public Parser(){ | |||
File file = new File("C:\\Users\\AntonioFrische\\OneDrive - ABACCO Solutions\\Documents\\Schule_22_23_CFGS\\Acceso_Datos\\IntelliJProyect\\XMLParser\\src\\main\\resources\\Empleados"); | |||
try { | |||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); | |||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); | |||
Document doc = dBuilder.parse(file); | |||
doc.getDocumentElement().normalize(); | |||
NodeList nList = doc.getElementsByTagName("empleado"); | |||
empleados = new Empleado[nList.getLength()]; | |||
for (int i = 0; i < nList.getLength(); i++){ | |||
Node nNode = nList.item(i); | |||
if(nNode.getNodeType() == Node.ELEMENT_NODE) { | |||
Element eElement = (Element) nNode; | |||
String id = eElement.getAttribute("id"); | |||
String apellido = eElement.getElementsByTagName("apellido").item(0).getTextContent(); | |||
String departemento = eElement.getElementsByTagName("dep").item(0).getTextContent(); | |||
String salario = eElement.getElementsByTagName("salario").item(0).getTextContent(); | |||
empleados[i] = new Empleado(id,apellido,departemento,salario); | |||
} | |||
} | |||
} catch(Exception e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
public Empleado[] getEmpleados(){ | |||
return empleados; | |||
} | |||
} |
@ -0,0 +1,18 @@ | |||
<?xml version="1.0" encoding="UTF-8" ?> | |||
<Empleados> | |||
<empleado id="1"> | |||
<apellido>Martinez</apellido> | |||
<dep>10</dep> | |||
<salario>1000.33</salario> | |||
</empleado> | |||
<empleado id="2"> | |||
<apellido>Garcia</apellido> | |||
<dep>11</dep> | |||
<salario>2000.34</salario> | |||
</empleado> | |||
<empleado id="3"> | |||
<apellido>Navarro</apellido> | |||
<dep>10</dep> | |||
<salario>2222.33</salario> | |||
</empleado> | |||
</Empleados> |