| @ -0,0 +1,55 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <classpath> | |||||
| <classpathentry kind="src" output="target/classes" path="src/main/java"> | |||||
| <attributes> | |||||
| <attribute name="optional" value="true"/> | |||||
| <attribute name="maven.pomderived" value="true"/> | |||||
| </attributes> | |||||
| </classpathentry> | |||||
| <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | |||||
| <attributes> | |||||
| <attribute name="maven.pomderived" value="true"/> | |||||
| </attributes> | |||||
| </classpathentry> | |||||
| <classpathentry kind="src" output="target/test-classes" path="src/test/java"> | |||||
| <attributes> | |||||
| <attribute name="optional" value="true"/> | |||||
| <attribute name="maven.pomderived" value="true"/> | |||||
| <attribute name="test" value="true"/> | |||||
| </attributes> | |||||
| </classpathentry> | |||||
| <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> | |||||
| <attributes> | |||||
| <attribute name="maven.pomderived" value="true"/> | |||||
| <attribute name="test" value="true"/> | |||||
| </attributes> | |||||
| </classpathentry> | |||||
| <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"> | |||||
| <attributes> | |||||
| <attribute name="maven.pomderived" value="true"/> | |||||
| </attributes> | |||||
| </classpathentry> | |||||
| <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | |||||
| <attributes> | |||||
| <attribute name="maven.pomderived" value="true"/> | |||||
| </attributes> | |||||
| </classpathentry> | |||||
| <classpathentry kind="src" path="target/generated-sources/annotations"> | |||||
| <attributes> | |||||
| <attribute name="optional" value="true"/> | |||||
| <attribute name="maven.pomderived" value="true"/> | |||||
| <attribute name="ignore_optional_problems" value="true"/> | |||||
| <attribute name="m2e-apt" value="true"/> | |||||
| </attributes> | |||||
| </classpathentry> | |||||
| <classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations"> | |||||
| <attributes> | |||||
| <attribute name="optional" value="true"/> | |||||
| <attribute name="maven.pomderived" value="true"/> | |||||
| <attribute name="ignore_optional_problems" value="true"/> | |||||
| <attribute name="m2e-apt" value="true"/> | |||||
| <attribute name="test" value="true"/> | |||||
| </attributes> | |||||
| </classpathentry> | |||||
| <classpathentry kind="output" path="target/classes"/> | |||||
| </classpath> | |||||
| @ -0,0 +1,8 @@ | |||||
| # Default ignored files | |||||
| /shelf/ | |||||
| /workspace.xml | |||||
| # Editor-based HTTP Client requests | |||||
| /httpRequests/ | |||||
| # Datasource local storage ignored files | |||||
| /dataSources/ | |||||
| /dataSources.local.xml | |||||
| @ -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="primerEjemplo" /> | |||||
| </profile> | |||||
| </annotationProcessing> | |||||
| <bytecodeTargetLevel target="10"> | |||||
| <module name="primerEjemplo" target="16" /> | |||||
| </bytecodeTargetLevel> | |||||
| </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="Central Repository" /> | |||||
| <option name="url" value="https://repo.maven.apache.org/maven2" /> | |||||
| </remote-repository> | |||||
| <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> | |||||
| </component> | |||||
| </project> | |||||
| @ -0,0 +1,13 @@ | |||||
| <component name="libraryTable"> | |||||
| <library name="Maven: com.github.javafaker:javafaker:1.0.2"> | |||||
| <CLASSES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/com/github/javafaker/javafaker/1.0.2/javafaker-1.0.2.jar!/" /> | |||||
| </CLASSES> | |||||
| <JAVADOC> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/com/github/javafaker/javafaker/1.0.2/javafaker-1.0.2-javadoc.jar!/" /> | |||||
| </JAVADOC> | |||||
| <SOURCES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/com/github/javafaker/javafaker/1.0.2/javafaker-1.0.2-sources.jar!/" /> | |||||
| </SOURCES> | |||||
| </library> | |||||
| </component> | |||||
| @ -0,0 +1,13 @@ | |||||
| <component name="libraryTable"> | |||||
| <library name="Maven: com.github.mifmif:generex:1.0.2"> | |||||
| <CLASSES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/com/github/mifmif/generex/1.0.2/generex-1.0.2.jar!/" /> | |||||
| </CLASSES> | |||||
| <JAVADOC> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/com/github/mifmif/generex/1.0.2/generex-1.0.2-javadoc.jar!/" /> | |||||
| </JAVADOC> | |||||
| <SOURCES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/com/github/mifmif/generex/1.0.2/generex-1.0.2-sources.jar!/" /> | |||||
| </SOURCES> | |||||
| </library> | |||||
| </component> | |||||
| @ -0,0 +1,13 @@ | |||||
| <component name="libraryTable"> | |||||
| <library name="Maven: dk.brics.automaton:automaton:1.11-8"> | |||||
| <CLASSES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/dk/brics/automaton/automaton/1.11-8/automaton-1.11-8.jar!/" /> | |||||
| </CLASSES> | |||||
| <JAVADOC> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/dk/brics/automaton/automaton/1.11-8/automaton-1.11-8-javadoc.jar!/" /> | |||||
| </JAVADOC> | |||||
| <SOURCES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/dk/brics/automaton/automaton/1.11-8/automaton-1.11-8-sources.jar!/" /> | |||||
| </SOURCES> | |||||
| </library> | |||||
| </component> | |||||
| @ -0,0 +1,13 @@ | |||||
| <component name="libraryTable"> | |||||
| <library name="Maven: org.apache.commons:commons-lang3:3.5"> | |||||
| <CLASSES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-lang3/3.5/commons-lang3-3.5.jar!/" /> | |||||
| </CLASSES> | |||||
| <JAVADOC> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-lang3/3.5/commons-lang3-3.5-javadoc.jar!/" /> | |||||
| </JAVADOC> | |||||
| <SOURCES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-lang3/3.5/commons-lang3-3.5-sources.jar!/" /> | |||||
| </SOURCES> | |||||
| </library> | |||||
| </component> | |||||
| @ -0,0 +1,13 @@ | |||||
| <component name="libraryTable"> | |||||
| <library name="Maven: org.json:json:20140107"> | |||||
| <CLASSES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/json/json/20140107/json-20140107.jar!/" /> | |||||
| </CLASSES> | |||||
| <JAVADOC> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/json/json/20140107/json-20140107-javadoc.jar!/" /> | |||||
| </JAVADOC> | |||||
| <SOURCES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/json/json/20140107/json-20140107-sources.jar!/" /> | |||||
| </SOURCES> | |||||
| </library> | |||||
| </component> | |||||
| @ -0,0 +1,13 @@ | |||||
| <component name="libraryTable"> | |||||
| <library name="Maven: org.springframework:spring-aop:5.3.23"> | |||||
| <CLASSES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-aop/5.3.23/spring-aop-5.3.23.jar!/" /> | |||||
| </CLASSES> | |||||
| <JAVADOC> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-aop/5.3.23/spring-aop-5.3.23-javadoc.jar!/" /> | |||||
| </JAVADOC> | |||||
| <SOURCES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-aop/5.3.23/spring-aop-5.3.23-sources.jar!/" /> | |||||
| </SOURCES> | |||||
| </library> | |||||
| </component> | |||||
| @ -0,0 +1,13 @@ | |||||
| <component name="libraryTable"> | |||||
| <library name="Maven: org.springframework:spring-beans:5.3.23"> | |||||
| <CLASSES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-beans/5.3.23/spring-beans-5.3.23.jar!/" /> | |||||
| </CLASSES> | |||||
| <JAVADOC> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-beans/5.3.23/spring-beans-5.3.23-javadoc.jar!/" /> | |||||
| </JAVADOC> | |||||
| <SOURCES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-beans/5.3.23/spring-beans-5.3.23-sources.jar!/" /> | |||||
| </SOURCES> | |||||
| </library> | |||||
| </component> | |||||
| @ -0,0 +1,13 @@ | |||||
| <component name="libraryTable"> | |||||
| <library name="Maven: org.springframework:spring-context:5.3.23"> | |||||
| <CLASSES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/5.3.23/spring-context-5.3.23.jar!/" /> | |||||
| </CLASSES> | |||||
| <JAVADOC> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/5.3.23/spring-context-5.3.23-javadoc.jar!/" /> | |||||
| </JAVADOC> | |||||
| <SOURCES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/5.3.23/spring-context-5.3.23-sources.jar!/" /> | |||||
| </SOURCES> | |||||
| </library> | |||||
| </component> | |||||
| @ -0,0 +1,13 @@ | |||||
| <component name="libraryTable"> | |||||
| <library name="Maven: org.springframework:spring-core:5.3.23"> | |||||
| <CLASSES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-core/5.3.23/spring-core-5.3.23.jar!/" /> | |||||
| </CLASSES> | |||||
| <JAVADOC> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-core/5.3.23/spring-core-5.3.23-javadoc.jar!/" /> | |||||
| </JAVADOC> | |||||
| <SOURCES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-core/5.3.23/spring-core-5.3.23-sources.jar!/" /> | |||||
| </SOURCES> | |||||
| </library> | |||||
| </component> | |||||
| @ -0,0 +1,13 @@ | |||||
| <component name="libraryTable"> | |||||
| <library name="Maven: org.springframework:spring-expression:5.3.23"> | |||||
| <CLASSES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-expression/5.3.23/spring-expression-5.3.23.jar!/" /> | |||||
| </CLASSES> | |||||
| <JAVADOC> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-expression/5.3.23/spring-expression-5.3.23-javadoc.jar!/" /> | |||||
| </JAVADOC> | |||||
| <SOURCES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-expression/5.3.23/spring-expression-5.3.23-sources.jar!/" /> | |||||
| </SOURCES> | |||||
| </library> | |||||
| </component> | |||||
| @ -0,0 +1,13 @@ | |||||
| <component name="libraryTable"> | |||||
| <library name="Maven: org.springframework:spring-jcl:5.3.23"> | |||||
| <CLASSES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-jcl/5.3.23/spring-jcl-5.3.23.jar!/" /> | |||||
| </CLASSES> | |||||
| <JAVADOC> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-jcl/5.3.23/spring-jcl-5.3.23-javadoc.jar!/" /> | |||||
| </JAVADOC> | |||||
| <SOURCES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-jcl/5.3.23/spring-jcl-5.3.23-sources.jar!/" /> | |||||
| </SOURCES> | |||||
| </library> | |||||
| </component> | |||||
| @ -0,0 +1,13 @@ | |||||
| <component name="libraryTable"> | |||||
| <library name="Maven: org.yaml:snakeyaml:android:1.23"> | |||||
| <CLASSES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.23/snakeyaml-1.23-android.jar!/" /> | |||||
| </CLASSES> | |||||
| <JAVADOC> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.23/snakeyaml-1.23-javadoc.jar!/" /> | |||||
| </JAVADOC> | |||||
| <SOURCES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.23/snakeyaml-1.23-sources.jar!/" /> | |||||
| </SOURCES> | |||||
| </library> | |||||
| </component> | |||||
| @ -0,0 +1,11 @@ | |||||
| <component name="libraryTable"> | |||||
| <library name="github.java.json.tools.btf" type="repository"> | |||||
| <properties maven-id="com.github.java-json-tools:btf:1.3" /> | |||||
| <CLASSES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/com/github/java-json-tools/btf/1.3/btf-1.3.jar!/" /> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar!/" /> | |||||
| </CLASSES> | |||||
| <JAVADOC /> | |||||
| <SOURCES /> | |||||
| </library> | |||||
| </component> | |||||
| @ -0,0 +1,15 @@ | |||||
| <component name="libraryTable"> | |||||
| <library name="springframework.spring.context" type="repository"> | |||||
| <properties maven-id="org.springframework:spring-context:5.0.1.RELEASE" /> | |||||
| <CLASSES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/5.0.1.RELEASE/spring-context-5.0.1.RELEASE.jar!/" /> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-aop/5.0.1.RELEASE/spring-aop-5.0.1.RELEASE.jar!/" /> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-beans/5.0.1.RELEASE/spring-beans-5.0.1.RELEASE.jar!/" /> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-core/5.0.1.RELEASE/spring-core-5.0.1.RELEASE.jar!/" /> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-jcl/5.0.1.RELEASE/spring-jcl-5.0.1.RELEASE.jar!/" /> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-expression/5.0.1.RELEASE/spring-expression-5.0.1.RELEASE.jar!/" /> | |||||
| </CLASSES> | |||||
| <JAVADOC /> | |||||
| <SOURCES /> | |||||
| </library> | |||||
| </component> | |||||
| @ -0,0 +1,10 @@ | |||||
| <component name="libraryTable"> | |||||
| <library name="springframework.spring.context.indexer" type="repository"> | |||||
| <properties maven-id="org.springframework:spring-context-indexer:5.1.8.RELEASE" /> | |||||
| <CLASSES> | |||||
| <root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-context-indexer/5.1.8.RELEASE/spring-context-indexer-5.1.8.RELEASE.jar!/" /> | |||||
| </CLASSES> | |||||
| <JAVADOC /> | |||||
| <SOURCES /> | |||||
| </library> | |||||
| </component> | |||||
| @ -0,0 +1,13 @@ | |||||
| <?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="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="corretto-18" project-jdk-type="JavaSDK"> | |||||
| <output url="file://$PROJECT_DIR$" /> | |||||
| </component> | |||||
| </project> | |||||
| @ -0,0 +1,8 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <project version="4"> | |||||
| <component name="ProjectModuleManager"> | |||||
| <modules> | |||||
| <module fileurl="file://$PROJECT_DIR$/primerEjemplo.iml" filepath="$PROJECT_DIR$/primerEjemplo.iml" /> | |||||
| </modules> | |||||
| </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,34 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <projectDescription> | |||||
| <name>primerEjemplo</name> | |||||
| <comment></comment> | |||||
| <projects> | |||||
| </projects> | |||||
| <buildSpec> | |||||
| <buildCommand> | |||||
| <name>org.eclipse.jdt.core.javabuilder</name> | |||||
| <arguments> | |||||
| </arguments> | |||||
| </buildCommand> | |||||
| <buildCommand> | |||||
| <name>org.eclipse.m2e.core.maven2Builder</name> | |||||
| <arguments> | |||||
| </arguments> | |||||
| </buildCommand> | |||||
| </buildSpec> | |||||
| <natures> | |||||
| <nature>org.eclipse.jdt.core.javanature</nature> | |||||
| <nature>org.eclipse.m2e.core.maven2Nature</nature> | |||||
| </natures> | |||||
| <filteredResources> | |||||
| <filter> | |||||
| <id>1668183688460</id> | |||||
| <name></name> | |||||
| <type>30</type> | |||||
| <matcher> | |||||
| <id>org.eclipse.core.resources.regexFilterMatcher</id> | |||||
| <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments> | |||||
| </matcher> | |||||
| </filter> | |||||
| </filteredResources> | |||||
| </projectDescription> | |||||
| @ -0,0 +1,2 @@ | |||||
| eclipse.preferences.version=1 | |||||
| org.eclipse.jdt.apt.aptEnabled=false | |||||
| @ -0,0 +1,8 @@ | |||||
| eclipse.preferences.version=1 | |||||
| org.eclipse.jdt.core.compiler.annotation.nonnull=org.springframework.lang.NonNull | |||||
| org.eclipse.jdt.core.compiler.annotation.nullable=org.springframework.lang.Nullable | |||||
| org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled | |||||
| org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning | |||||
| org.eclipse.jdt.core.compiler.problem.nullReference=warning | |||||
| org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning | |||||
| org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning | |||||
| @ -0,0 +1,4 @@ | |||||
| activeProfiles= | |||||
| eclipse.preferences.version=1 | |||||
| resolveWorkspaceProjects=true | |||||
| version=1 | |||||
| @ -0,0 +1,53 @@ | |||||
| <h1>ANOTACIONES </h1> | |||||
| <h3>Autowired </h3> | |||||
| <p>Tiene el mismo efecto que la configuracion via XML</p> | |||||
| <p>Busca un bean y lo inyecta en la depencia</p> | |||||
| <p>Se realiza un autocableado byType </p> | |||||
| <h4>*****Donde lo podemos usar******</h4> | |||||
| <p>Lo podemos utilizar en un metodo setter</p> | |||||
| ```java | |||||
| @Autowired | |||||
| public void setPeliculas(PeliculasServicio peliculasServicio){....} | |||||
| ``` | |||||
| <p>Definicion en la propiedad</p> | |||||
| ```java | |||||
| @Autowired | |||||
| private PeliculaServicio peliculaServicio; | |||||
| ``` | |||||
| <p>En el constructor</p> | |||||
| ```java | |||||
| @Autowired | |||||
| public PeliculaServicio(PeliculaServicio){....} | |||||
| ``` | |||||
| <p>Ejemplo en el xml </p> | |||||
| ```xml | |||||
| <bean id="peliculaDaoMemory" | |||||
| class="com.primerEjemplo.PeliculaImplements" | |||||
| init-method="cargarDatos" /> | |||||
| <bean id="peliculaService" class="com.primerEjemplo.Modelo.PeliculaServicio" autowire="byType"/> | |||||
| ``` | |||||
| <p>Ejemplo del main</p> | |||||
| ```java | |||||
| // Necesitamos el bean de servicios para printar por pantalla la logica | |||||
| PeliculaServicio peliculaService = appContext.getBean(PeliculaServicio.class); | |||||
| peliculaService.peliculasPorGenero("Drama").forEach(System.out::println); | |||||
| appContext.close(); | |||||
| ``` | |||||
| @ -0,0 +1,47 @@ | |||||
| <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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
| <modelVersion>4.0.0</modelVersion> | |||||
| <groupId>com.primerEjemplo</groupId> | |||||
| <artifactId>primerEjemplo</artifactId> | |||||
| <version>0.0.1-SNAPSHOT</version> | |||||
| <build> | |||||
| <plugins> | |||||
| <plugin> | |||||
| <groupId>org.apache.maven.plugins</groupId> | |||||
| <artifactId>maven-compiler-plugin</artifactId> | |||||
| <configuration> | |||||
| <source>16</source> | |||||
| <target>16</target> | |||||
| </configuration> | |||||
| </plugin> | |||||
| </plugins> | |||||
| </build> | |||||
| <!-- https://mvnrepository.com/artifact/org.springframework/spring-context --> | |||||
| <dependencies> | |||||
| <dependency> | |||||
| <groupId>org.springframework</groupId> | |||||
| <artifactId>spring-context</artifactId> | |||||
| <version>5.3.23</version> | |||||
| </dependency> | |||||
| <!-- https://mvnrepository.com/artifact/org.json/json --> | |||||
| <dependency> | |||||
| <groupId>org.json</groupId> | |||||
| <artifactId>json</artifactId> | |||||
| <version>20140107</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>com.github.javafaker</groupId> | |||||
| <artifactId>javafaker</artifactId> | |||||
| <version>1.0.2</version> | |||||
| </dependency> | |||||
| </dependencies> | |||||
| <properties> | |||||
| <maven.compiler.source>1.8</maven.compiler.source> | |||||
| <maven.compiler.target>1.8</maven.compiler.target> | |||||
| </properties> | |||||
| </project> | |||||
| @ -0,0 +1,40 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | |||||
| <component name="FacetManager"> | |||||
| <facet type="Spring" name="Spring"> | |||||
| <configuration> | |||||
| <fileset id="fileset" name="Spring Application Context" removed="false"> | |||||
| <file>file://$MODULE_DIR$/src/main/resources/beans.xml</file> | |||||
| </fileset> | |||||
| </configuration> | |||||
| </facet> | |||||
| </component> | |||||
| <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_16"> | |||||
| <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" /> | |||||
| <sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" /> | |||||
| <excludeFolder url="file://$MODULE_DIR$/target" /> | |||||
| </content> | |||||
| <orderEntry type="inheritedJdk" /> | |||||
| <orderEntry type="sourceFolder" forTests="false" /> | |||||
| <orderEntry type="library" name="github.java.json.tools.btf" level="project" /> | |||||
| <orderEntry type="library" name="springframework.spring.context" level="project" /> | |||||
| <orderEntry type="library" name="springframework.spring.context.indexer" level="project" /> | |||||
| <orderEntry type="library" name="Maven: org.springframework:spring-context:5.3.23" level="project" /> | |||||
| <orderEntry type="library" name="Maven: org.springframework:spring-aop:5.3.23" level="project" /> | |||||
| <orderEntry type="library" name="Maven: org.springframework:spring-beans:5.3.23" level="project" /> | |||||
| <orderEntry type="library" name="Maven: org.springframework:spring-core:5.3.23" level="project" /> | |||||
| <orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.3.23" level="project" /> | |||||
| <orderEntry type="library" name="Maven: org.springframework:spring-expression:5.3.23" level="project" /> | |||||
| <orderEntry type="library" name="Maven: org.json:json:20140107" level="project" /> | |||||
| <orderEntry type="library" name="Maven: com.github.javafaker:javafaker:1.0.2" level="project" /> | |||||
| <orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.5" level="project" /> | |||||
| <orderEntry type="library" name="Maven: org.yaml:snakeyaml:android:1.23" level="project" /> | |||||
| <orderEntry type="library" name="Maven: com.github.mifmif:generex:1.0.2" level="project" /> | |||||
| <orderEntry type="library" name="Maven: dk.brics.automaton:automaton:1.11-8" level="project" /> | |||||
| </component> | |||||
| </module> | |||||
| @ -0,0 +1,114 @@ | |||||
| package Lib; | |||||
| import java.util.IllegalFormatException; | |||||
| public class Ansi { | |||||
| public enum Color { | |||||
| BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, NONE | |||||
| } | |||||
| public enum ColorType { | |||||
| FOREGROUND, BACKGROUND | |||||
| } | |||||
| public static final String ESC = "\u001b["; | |||||
| public static final String RESET = ESC + "0m"; | |||||
| public static final String HIGH_INTENSITY = ESC + "[1m"; | |||||
| public static final String LOW_INTESITY = ESC + "[2m"; | |||||
| public static final String ITALIC = ESC + "[3m"; | |||||
| public static final String UNDERLINE = ESC + "[4m"; | |||||
| public static final String BLINK = ESC + "[5m"; | |||||
| public static final String RAPID_BLINK = ESC + "[6m"; | |||||
| public static final String REVERSE_VIDEO = ESC + "[7m"; | |||||
| public static final String INVISIBLE_TEXT = ESC + "[8m"; | |||||
| private Ansi() { } | |||||
| public static Color randomColor() { | |||||
| int min = 0; | |||||
| int max = Color.values().length - 1; | |||||
| int alea =Util.random(min, max); | |||||
| return Color.values()[alea]; | |||||
| } | |||||
| public static void print(char c, Color fg, Color bg) { | |||||
| printTo(c, -1, -1, false, fg, bg); | |||||
| } | |||||
| public static void printTo(char c, int col, int row) { | |||||
| printTo(c, col, row, false, Color.NONE, Color.NONE); | |||||
| } | |||||
| public static void printTo(char c, int col, int row, boolean bold, Color fg, Color bg) { | |||||
| String color = getColorStr(bold, fg, bg); | |||||
| if(row > 0 || col > 0) | |||||
| System.out.print(ESC + row + ";" + col + "f"); | |||||
| System.out.print(color + c); | |||||
| if(!color.isEmpty()) | |||||
| System.out.print(RESET); | |||||
| System.out.flush(); | |||||
| } | |||||
| private static String getColorStr(boolean bold, Color fg, Color bg) { | |||||
| String fgColor = getColor(fg, ColorType.FOREGROUND); | |||||
| String bgColor = getColor(bg, ColorType.BACKGROUND); | |||||
| String negrita = (bold ? "1" : "0"); | |||||
| String color = ""; | |||||
| if(!fgColor.isEmpty() || !bgColor.isEmpty()) { | |||||
| color = ESC + negrita; | |||||
| color += (!fgColor.isEmpty() ? ";" + fgColor : ""); | |||||
| color += (!bgColor.isEmpty() ? ";" + bgColor : ""); | |||||
| color += "m"; | |||||
| } | |||||
| return color; | |||||
| } | |||||
| public static String format(String s, boolean bold, Color fg, Color bg, Object...args) throws IllegalFormatException { | |||||
| String color = getColorStr(bold, fg, bg); | |||||
| return color + String.format(s, args) + RESET; | |||||
| } | |||||
| public static void printf(String s, boolean bold, Color fg, Color bg, Object...args) throws IllegalFormatException { | |||||
| String color = getColorStr(bold, fg, bg); | |||||
| // String text = String.format(s, args); | |||||
| System.out.printf(color + s, args); | |||||
| System.out.print(RESET); | |||||
| System.out.flush(); | |||||
| } | |||||
| public static String getColor(Color c, ColorType ct) { | |||||
| String result = ""; | |||||
| if(c != Color.NONE) { | |||||
| switch(ct) { | |||||
| case FOREGROUND: | |||||
| result = "3" + c.ordinal(); | |||||
| break; | |||||
| case BACKGROUND: | |||||
| result = "4" + c.ordinal(); | |||||
| break; | |||||
| } | |||||
| } | |||||
| return result; | |||||
| } | |||||
| public static void clearScreen() { | |||||
| System.out.print(ESC + "H"); | |||||
| System.out.print(ESC + "2J"); | |||||
| System.out.flush(); | |||||
| } | |||||
| public static void hideCursor() { | |||||
| System.out.print(ESC + "?25l"); | |||||
| System.out.flush(); | |||||
| } | |||||
| public static void showCursor() { | |||||
| System.out.print(ESC + "?25h"); | |||||
| System.out.flush(); | |||||
| } | |||||
| public static void cleanScreen() { | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,36 @@ | |||||
| package Lib; | |||||
| import java.util.Random;; | |||||
| public class Bombo { | |||||
| private final int[] array; | |||||
| private int validos; | |||||
| private final Random random; | |||||
| public Bombo(int cantidadElementos, int valorMinimo) { | |||||
| random = new Random(); | |||||
| array = new int[cantidadElementos]; | |||||
| for (int i = 0; i < array.length; i++) { | |||||
| array[i] = valorMinimo; | |||||
| valorMinimo++; | |||||
| } | |||||
| validos = cantidadElementos - 1; | |||||
| } | |||||
| public int extraerBola() { | |||||
| if (validos >= 0) { | |||||
| int indice = random.nextInt(validos - 0 + 1) + 0; | |||||
| int numero = array[indice]; | |||||
| array[indice] = array[validos]; | |||||
| array[validos] = numero; | |||||
| validos--; | |||||
| return numero; | |||||
| } | |||||
| return Integer.MIN_VALUE; | |||||
| } | |||||
| public void reset() { | |||||
| validos = array.length - 1; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,438 @@ | |||||
| package Lib; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.time.LocalDate; | |||||
| import java.util.Arrays; | |||||
| import java.util.Calendar; | |||||
| import java.util.Date; | |||||
| import java.util.GregorianCalendar; | |||||
| import java.util.concurrent.ThreadLocalRandom; | |||||
| import java.util.regex.Pattern; | |||||
| public class Control { | |||||
| private static String userStr; | |||||
| private static int usrInt; | |||||
| private static boolean correct; | |||||
| private static final Pattern REGEXP = Pattern.compile("[0-9]{8}[A-Z]"); | |||||
| private static final Pattern REGEXP1 = Pattern.compile("[0-9]{8}"); | |||||
| private static final String DIGITO_CONTROL = "TRWAGMYFPDXBNJZSQVHLCKE"; | |||||
| private static final String[] INVALIDOS = new String[]{"00000000T", "00000001R", "99999999R"}; | |||||
| /** | |||||
| * @param tittle for your menu | |||||
| * @param sentence/s for your choices | |||||
| * @returns the value of your choice | |||||
| */ | |||||
| public static int menuGenerator(String tittle, String[] sentence) { | |||||
| System.out.println("\n*****************"); | |||||
| System.out.printf("** %S **\n", tittle); | |||||
| System.out.println("*****************\n"); | |||||
| for (int i = 0; i < sentence.length; i++) { | |||||
| sentence[i] = String.format("%d %S\n", (i), sentence[i]); | |||||
| System.out.println(sentence[i]); | |||||
| } | |||||
| System.out.println("Choose one option"); | |||||
| int option = Integer.parseInt(Util.myInput.nextLine()); | |||||
| boolean correct = option > 0; | |||||
| do { | |||||
| if (option > sentence.length) { | |||||
| System.out.println("Please your answer must be between the range"); | |||||
| option = -1; | |||||
| } else { | |||||
| Ansi.clearScreen(); | |||||
| return option; | |||||
| } | |||||
| } while (!correct); | |||||
| return option; | |||||
| } | |||||
| /** | |||||
| * @param initializer | |||||
| * @param tittle | |||||
| * @param sentence | |||||
| * @return | |||||
| */ | |||||
| public static int menuGenerator(int initializer, String tittle, String[] sentence) { | |||||
| System.out.println("\n*****************"); | |||||
| System.out.printf("** %S **\n", tittle); | |||||
| System.out.println("*****************\n"); | |||||
| for (int i = initializer; i < sentence.length; i++) { | |||||
| sentence[i] = String.format("%d %S\n", (i), sentence[i]); | |||||
| System.out.println(sentence[i]); | |||||
| } | |||||
| System.out.println("Choose one option"); | |||||
| int option = Integer.parseInt(Util.myInput.nextLine()); | |||||
| if (option > sentence.length) { | |||||
| System.out.println("Please your answer must be between the range"); | |||||
| option = -1; | |||||
| } else { | |||||
| Ansi.clearScreen(); | |||||
| return option; | |||||
| } | |||||
| return option; | |||||
| } | |||||
| public static int getEdad(GregorianCalendar edad) { | |||||
| int anyoNacimiento = edad.get(Calendar.YEAR); | |||||
| int mesNacimiento = edad.get(Calendar.MONTH) + 1; // | |||||
| int diaNacimiento = edad.get(Calendar.DAY_OF_MONTH); | |||||
| GregorianCalendar fecha = new GregorianCalendar(); | |||||
| int anyoActual = fecha.get(Calendar.YEAR); | |||||
| int mesActual = fecha.get(Calendar.MONTH) + 1; | |||||
| int diaActual = fecha.get(Calendar.DAY_OF_MONTH); | |||||
| int edad1 = anyoActual - anyoNacimiento; | |||||
| if (mesActual < mesNacimiento) { | |||||
| edad1--; | |||||
| } else if (mesActual == mesNacimiento) { | |||||
| if (diaActual < diaNacimiento) { | |||||
| edad1--; | |||||
| } | |||||
| } | |||||
| return edad1; | |||||
| } | |||||
| /** | |||||
| * @param min introduce the minimum date you want | |||||
| * @param max introduce the maximum date you want | |||||
| * @return | |||||
| */ | |||||
| public static GregorianCalendar randBirth(int min, int max) { | |||||
| GregorianCalendar gc = new GregorianCalendar(); | |||||
| // we create a date between these two years | |||||
| // int year = Lib.randBetween(1900, 2010); | |||||
| if (min < 1900) { | |||||
| System.out.println("The date needs to be greater than " + min); | |||||
| } | |||||
| int year = Util.randBetween(min, max); | |||||
| // we set the our own year to one gc YEAR | |||||
| gc.set(gc.YEAR, year); | |||||
| // get a random day of the year | |||||
| int dayOfYear = Util.randBetween(1, gc.getActualMaximum(gc.DAY_OF_YEAR)); | |||||
| // then we obtain our last item | |||||
| gc.set(gc.DAY_OF_YEAR, dayOfYear); | |||||
| // print out an example(*we need to format this in order to print this | |||||
| // correctly) | |||||
| // System.out.println(gc.get(gc.YEAR) + "-" + (gc.get(gc.MONTH) + 1) + "-" + | |||||
| // gc.get(gc.DAY_OF_MONTH)); | |||||
| return gc; | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @return gregoriancalendar formated () that the user has introduced | |||||
| */ | |||||
| // public static GregorianCalendar birthFormat() { | |||||
| // System.out.println(" Fecha (dd-mm-yyyy)"); | |||||
| // userStr = Util.myInput.nextLine(); | |||||
| // SimpleDateFormat sdf = new SimpleDateFormat("DD-MM-YYYY"); | |||||
| // // GregorianCalendar birth = null; | |||||
| // do { | |||||
| // try { | |||||
| // Date date = sdf.parse(userStr); | |||||
| // birth = new GregorianCalendar(); | |||||
| // birth.setTime(date); | |||||
| // correct = true; | |||||
| // } catch (Exception e) { | |||||
| // correct = false; | |||||
| // System.out.println("The format that you've introduced is not correct"); | |||||
| // } | |||||
| // } while (!correct); | |||||
| // return birth; | |||||
| // } | |||||
| /** | |||||
| * @return gregoriancalendar formated () that the user has introduced | |||||
| */ | |||||
| public static String birthFormat(GregorianCalendar yourDate) { | |||||
| SimpleDateFormat sdf = new SimpleDateFormat("DD-MM-YYYY"); | |||||
| String dateFormatted = sdf.format( | |||||
| yourDate.getTime()); | |||||
| return dateFormatted; | |||||
| } | |||||
| /** | |||||
| * @param <T> | |||||
| * @param yourDate | |||||
| * @return the formatted date | |||||
| */ | |||||
| public static <T> String dateFormated(T yourDate) { | |||||
| SimpleDateFormat sdf = new SimpleDateFormat("DD-MM-YYYY"); | |||||
| String dateFormatted = sdf.format( | |||||
| ((Calendar) yourDate).getTime()); | |||||
| return dateFormatted; | |||||
| } | |||||
| /** | |||||
| * @param message introduce the message you want to ask to the user | |||||
| * @param validate validate each one of your validated options | |||||
| * @return true if it matches any asnwers and false if it does not. | |||||
| */ | |||||
| public static boolean one(String message, char[] validate) { | |||||
| int index = 0; | |||||
| System.out.printf(message); | |||||
| char c = Util.myInput.nextLine().toLowerCase().charAt(index); | |||||
| for (int i = 0; i < validate.length; i++) { | |||||
| if (validate[i] == c) { | |||||
| correct = true; | |||||
| } else { | |||||
| correct = false; | |||||
| } | |||||
| } | |||||
| return correct; | |||||
| } | |||||
| /** | |||||
| * @param message introduce the message you want to ask to the user | |||||
| * @param validate validate the option you want to compare if it is equal to | |||||
| * other one. | |||||
| * @return true if it matches any asnwers and false if it does not. | |||||
| */ | |||||
| public static boolean one(String message, char validate) { | |||||
| int index = 0; | |||||
| System.out.println(message); | |||||
| String validateStr = validate + ""; | |||||
| validate = validateStr.toLowerCase().charAt(index); | |||||
| char c = Util.myInput.nextLine().toLowerCase().charAt(index); | |||||
| if (validate == c) | |||||
| return true; | |||||
| return false; | |||||
| } | |||||
| public static boolean one(char[] validate, char election) { | |||||
| for (int i = 0; i < validate.length; i++) { | |||||
| if (validate[i] == election) { | |||||
| correct = true; | |||||
| } else { | |||||
| correct = false; | |||||
| } | |||||
| } | |||||
| return correct; | |||||
| } | |||||
| /** | |||||
| * @param dni introduce 8 digits for your dni | |||||
| * @return the correct char for your dni (String) | |||||
| */ | |||||
| public static String DNIgeneratorChar(int dni) { | |||||
| String str = "TRWAGMYFPDXBNJZSQVHLCKE"; | |||||
| char letra = 'a'; | |||||
| int result = dni % str.length(); | |||||
| String dniStr = null; | |||||
| dniStr = String.valueOf(dni); | |||||
| if (REGEXP1.matcher(dniStr).matches()) { | |||||
| letra = str.charAt(result); | |||||
| } else { | |||||
| System.out.print("Dni invalido\n"); | |||||
| System.out.println("Presione enter para continuar..."); | |||||
| Util.myInput.nextLine(); | |||||
| } | |||||
| return dniStr + letra; | |||||
| } | |||||
| /** | |||||
| * @param dni introduce 8 digits for your dni | |||||
| * @return the correct char for your dni (String) | |||||
| */ | |||||
| public static String DNIgeneratorChar(String dni) { | |||||
| String str = "TRWAGMYFPDXBNJZSQVHLCKE"; | |||||
| char letra = 'a'; | |||||
| // parsing the dni String to int in order to give us the correct mod for the | |||||
| // calculation | |||||
| int intDni = Integer.parseInt(dni); | |||||
| int result = intDni % str.length(); | |||||
| String dniStr = null; | |||||
| // parsing the dni int to String | |||||
| dniStr = String.valueOf(dni); | |||||
| if (REGEXP1.matcher(dniStr).matches()) { | |||||
| letra = str.charAt(result); | |||||
| } else { | |||||
| System.out.print("Dni invalido\n"); | |||||
| System.out.println("Presione enter para continuar..."); | |||||
| Util.myInput.nextLine(); | |||||
| } | |||||
| return dniStr + letra; | |||||
| } | |||||
| /** | |||||
| * @param dni validates your dni | |||||
| * @return true if its correct and false otherwise | |||||
| */ | |||||
| public boolean validateDNI(String dni) { | |||||
| return Arrays.binarySearch(INVALIDOS, dni) < 0 // (1) | |||||
| && REGEXP.matcher(dni).matches() // (2) | |||||
| && dni.charAt(8) == DIGITO_CONTROL.charAt(Integer.parseInt(dni.substring(0, 8)) % 23); // (3) | |||||
| } | |||||
| /** | |||||
| * @param numStr | |||||
| * @returns only digits from the inserted String | |||||
| */ | |||||
| public int strToInt(String numStr) { | |||||
| int num = 0; | |||||
| try { | |||||
| num = Integer.parseInt(numStr); | |||||
| } catch (NumberFormatException ex) { | |||||
| ex.printStackTrace(); | |||||
| } | |||||
| return num; | |||||
| } | |||||
| /** | |||||
| * @return generate a random localDate | |||||
| */ | |||||
| public static LocalDate rndLocalDate() { | |||||
| long minDay = LocalDate.of(1970, 1, 1).toEpochDay(); | |||||
| LocalDate lt = LocalDate.now(); | |||||
| int maxDay = lt.getYear(); | |||||
| long randomDay = ThreadLocalRandom.current().nextLong(minDay, maxDay); | |||||
| LocalDate randomDate = LocalDate.ofEpochDay(randomDay); | |||||
| return randomDate; | |||||
| } | |||||
| /** | |||||
| * @param min the year you wanna put | |||||
| * @return a random localDate | |||||
| */ | |||||
| public static LocalDate rndLocalDate(LocalDate min) { | |||||
| // long minDay = min.toEpochDay(); | |||||
| LocalDate lt = LocalDate.now(); | |||||
| int maxDay = lt.getYear(); | |||||
| int minDay = min.getYear(); | |||||
| // long randomDay = ThreadLocalRandom.current().nextLong(minDay, maxDay); | |||||
| long randomDay = ThreadLocalRandom.current().nextLong(minDay, maxDay); | |||||
| LocalDate randomDate = LocalDate.ofEpochDay(randomDay); | |||||
| return randomDate; | |||||
| } // public static GregorianCalendar birthFormat() { | |||||
| // System.out.println(" Fecha (dd-mm-yyyy)"); | |||||
| // userStr = Util.myInput.nextLine(); | |||||
| // SimpleDateFormat sdf = new SimpleDateFormat("DD-MM-YYYY"); | |||||
| // // GregorianCalendar birth = null; | |||||
| // do { | |||||
| // try { | |||||
| // Date date = sdf.parse(userStr); | |||||
| // birth = new GregorianCalendar(); | |||||
| // birth.setTime(date); | |||||
| // correct = true; | |||||
| // } catch (Exception e) { | |||||
| // correct = false; | |||||
| // System.out.println("The format that you've introduced is not correct"); | |||||
| // } | |||||
| // } while (!correct); | |||||
| // return birth; | |||||
| // } | |||||
| /** | |||||
| * @param <T> | |||||
| * @param values the enum you would like to loop | |||||
| * @return the choice you made | |||||
| */ | |||||
| public static <T extends Enum<T>> Enum<T> selectEnum(T[] values) { | |||||
| do { | |||||
| System.out.println("These are the options avaliable.\nPlease select one of these."); | |||||
| for (int i = 0; i < values.length; i++) { | |||||
| System.out.println(i + " " + values[i]); | |||||
| } | |||||
| String message = "Select a number "; | |||||
| int choice = Util.validateInt(message, 0, values.length); | |||||
| for (int i = 0; i < values.length; i++) { | |||||
| if (i == choice) { | |||||
| return values[i]; | |||||
| } else { | |||||
| correct = false; | |||||
| } | |||||
| } | |||||
| System.out.println("Your choice must be between the range"); | |||||
| } while (correct); | |||||
| return null; | |||||
| } | |||||
| /** | |||||
| * @param option you must select | |||||
| * @return the data that has matched with the input of the user; or null if it | |||||
| * doens't | |||||
| */ | |||||
| public static <T> T checkOptions(String[] option) { | |||||
| do { | |||||
| System.out.println("Introduce one answer for the avaliable options " + Arrays.toString(option)); | |||||
| String usr = Util.myInput.nextLine(); | |||||
| for (int i = 0; i < option.length; i++) { | |||||
| if (option[i].equalsIgnoreCase(usr)) { | |||||
| return (T) usr; | |||||
| } else { | |||||
| correct = false; | |||||
| } | |||||
| } | |||||
| System.out.println("Please insert a valid option"); | |||||
| } while (!correct); | |||||
| return null; | |||||
| } | |||||
| /** | |||||
| * @param min LocalDate you want to insert | |||||
| * @param max LocalDate youw ant to insert | |||||
| * @return random Date between the range | |||||
| */ | |||||
| public static LocalDate rndLD(LocalDate min, LocalDate max) { | |||||
| long minDay = LocalDate.of(min.getYear(), min.getMonth(), min.getDayOfMonth()).toEpochDay(); | |||||
| long maxDay = LocalDate.of(max.getYear(), max.getMonth(), max.getDayOfMonth()).toEpochDay(); | |||||
| long randomDay = ThreadLocalRandom.current().nextLong(minDay, maxDay); | |||||
| LocalDate rnDate = LocalDate.ofEpochDay(randomDay); | |||||
| return rnDate; | |||||
| } | |||||
| /** | |||||
| * @param dni | |||||
| * @return el dni | |||||
| */ | |||||
| public static char letraNIF(int dni) { | |||||
| String tabla = "TRWAGMYFPDXBNJZSQVHLCKE"; | |||||
| int modulo = dni % 23; | |||||
| return tabla.charAt(modulo); | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,57 @@ | |||||
| package Lib; | |||||
| import java.time.LocalDate; | |||||
| import java.time.ZoneId; | |||||
| import java.util.ArrayList; | |||||
| import java.util.GregorianCalendar; | |||||
| public class Conversion { | |||||
| static ArrayList<Object> arrayListObj = new ArrayList<Object>(); | |||||
| static ArrayList<Integer> arrayList = new ArrayList<Integer>(); | |||||
| private ArrayList<Object> maxSpeed; | |||||
| public static <T> ArrayList<Object> arrToArrListObj(T[] SPEEDARRAY) { | |||||
| for (T t : SPEEDARRAY) { | |||||
| arrayListObj.add(t); | |||||
| } | |||||
| return arrayListObj; | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @param <T> | |||||
| * @param SPEEDARRAY recieves a Generic array | |||||
| * @returns an Integer arrayList | |||||
| */ | |||||
| public static <T> ArrayList<Integer> arrToArrList(T[] SPEEDARRAY) { | |||||
| for (T t : SPEEDARRAY) { | |||||
| arrayList.add((Integer) t); | |||||
| } | |||||
| return arrayList; | |||||
| } | |||||
| public String showAll() { | |||||
| String concate = ""; | |||||
| for (Object integer : maxSpeed) { | |||||
| concate += (integer + ","); | |||||
| } | |||||
| return concate; | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @param date localdate | |||||
| * @return gregorianCalendar | |||||
| */ | |||||
| public static GregorianCalendar convertLDtoGre(LocalDate date) { | |||||
| GregorianCalendar gc = GregorianCalendar.from(date.atStartOfDay(ZoneId.systemDefault())); | |||||
| return gc; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,76 @@ | |||||
| package Lib; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Arrays; | |||||
| public class MyArr { | |||||
| /** | |||||
| * | |||||
| * @param original original array | |||||
| * @param implement the new array you want to merge with the previous one | |||||
| * @returns the new emerged array (int) | |||||
| */ | |||||
| public static int[] mergeArray(int original[], int implement[]) { | |||||
| int newLength = original.length + implement.length; | |||||
| int newArr[] = Arrays.copyOf(original, newLength); | |||||
| for (int i = 0; i < implement.length; i++) { | |||||
| newArr[original.length + i] = implement[i]; | |||||
| } | |||||
| return newArr; | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @param <T> | |||||
| * @param original | |||||
| * @param implement | |||||
| * @return the new implement obj array | |||||
| */ | |||||
| public static <T> T[] mergeArray(T original[], T implement[]) { | |||||
| int newLength = original.length + implement.length; | |||||
| T[] newArr = Arrays.copyOf(original, newLength); | |||||
| for (int i = 0; i < implement.length; i++) { | |||||
| newArr[original.length + i] = implement[i]; | |||||
| } | |||||
| return newArr; | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @param <T> | |||||
| * @param arr | |||||
| * @return the random obj selected | |||||
| */ | |||||
| public static <T> T getRndValueArr(T arr[]) { | |||||
| // Store the index in a variable | |||||
| // int rnd = (int) (Math.random() * arr.length); | |||||
| int rnd = (Util.random).nextInt(arr.length); | |||||
| // Then access it using another variable | |||||
| T random = (arr[rnd]); | |||||
| return random; | |||||
| } | |||||
| public static <T> Object[] mergeObj(Object[] eggs, Object[] perls) { | |||||
| int newLength = eggs.length + perls.length; | |||||
| Object[] newArr = Arrays.copyOf(eggs, newLength); | |||||
| try { | |||||
| for (int i = 0; i < perls.length; i++) { | |||||
| newArr[eggs.length + i] = perls[i]; | |||||
| } | |||||
| } catch (ArrayStoreException ase) { | |||||
| ase.printStackTrace(); | |||||
| } | |||||
| return newArr; | |||||
| } | |||||
| public String getRandom(ArrayList<String> array) { | |||||
| int index = 0; | |||||
| index = Util.random.nextInt(array.size()); | |||||
| System.out.println("This is the index " + index); | |||||
| // array.remove(index); | |||||
| return array.get(index); | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,315 @@ | |||||
| package Lib; | |||||
| import java.util.Scanner; | |||||
| import java.util.UUID; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.time.LocalDate; | |||||
| import java.time.format.DateTimeFormatter; | |||||
| import java.time.temporal.TemporalAccessor; | |||||
| import java.util.Date; | |||||
| import java.util.GregorianCalendar; | |||||
| import java.util.Random; | |||||
| public class Util { | |||||
| public static Scanner myInput = new Scanner(System.in); | |||||
| public static Random random = new Random(); | |||||
| private static boolean correct = true; | |||||
| public static void pause() { | |||||
| System.out.println("Press enter to continue ...."); | |||||
| myInput.nextLine(); | |||||
| } | |||||
| public static int randBetween(int start, int end) { | |||||
| return start + (int) Math.round(Math.random() * (end - start)); | |||||
| } | |||||
| public static int random(int min, int max) { | |||||
| Random r = new Random(); | |||||
| return r.nextInt(max - min + 1) + min; | |||||
| } | |||||
| public static double randomDouble(int min, int max) { | |||||
| Random r = new Random(); | |||||
| return r.nextInt(max - min + 1) + min; | |||||
| } | |||||
| public static void clearScreen() { | |||||
| System.out.println("\u000C"); | |||||
| } | |||||
| public static void cleanScreen() { | |||||
| System.out.print("\033[H\033[2J"); | |||||
| System.out.flush(); | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @param message | |||||
| * @param max | |||||
| * @param min | |||||
| * @return | |||||
| */ | |||||
| public static int validateInt(String message, int min, int max) { | |||||
| int userInt = 0; | |||||
| do { | |||||
| try { | |||||
| System.out.println(message); | |||||
| userInt = myInput.nextInt(); | |||||
| // userInt = Integer.parseInt(Util.myInput.nextLine()); | |||||
| if (correct = userInt >= min && userInt <= max) { | |||||
| correct = true; | |||||
| } else { | |||||
| System.out.println("The number must be between" + min + " and " + max); | |||||
| correct = false; | |||||
| } | |||||
| } catch (NumberFormatException e) { | |||||
| System.out.println("Error"); | |||||
| Util.pause(); | |||||
| } | |||||
| } while (!correct); | |||||
| return userInt; | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @param message to validate | |||||
| * @return DOUBLE | |||||
| */ | |||||
| public static double validateDouble(String message) { | |||||
| double userDouble = 0; | |||||
| do { | |||||
| try { | |||||
| System.out.println(message); | |||||
| userDouble = myInput.nextDouble(); | |||||
| // userDouble = Double.parseDouble(Util.myInput.nextLine()); | |||||
| correct = true; | |||||
| } catch (NumberFormatException e) { | |||||
| System.out.println("Error"); | |||||
| Util.pause(); | |||||
| } | |||||
| } while (!correct); | |||||
| return userDouble; | |||||
| } | |||||
| public static String validateString(String userStr, String errorMs) { | |||||
| userStr = null; | |||||
| String compare = ""; | |||||
| do { | |||||
| correct = userStr.equals(compare); | |||||
| System.out.println("Introduce un String "); | |||||
| try { | |||||
| userStr = Util.myInput.nextLine(); | |||||
| } catch (NumberFormatException e) { | |||||
| System.out.println(errorMs); | |||||
| correct = false; | |||||
| } | |||||
| } while (!correct); | |||||
| return userStr; | |||||
| } | |||||
| public String validateString1(String userStr) { | |||||
| userStr = null; | |||||
| String compare = ""; | |||||
| do { | |||||
| correct = userStr.equals(compare); | |||||
| System.out.println("Introduce un String "); | |||||
| try { | |||||
| userStr = Util.myInput.nextLine(); | |||||
| } catch (NumberFormatException e) { | |||||
| System.out.println("Error: El input no es un String"); | |||||
| correct = false; | |||||
| } | |||||
| } while (!correct); | |||||
| return userStr; | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @param message | |||||
| * @param minLenght | |||||
| * @param maxLenght | |||||
| * @return | |||||
| */ | |||||
| public static String validateString2(String message, int minLenght, int maxLenght) { | |||||
| String userStr; | |||||
| // No se inicializa porque este | |||||
| // si data hubiera sido un atributo hubiese sido inicializado como null | |||||
| do { | |||||
| System.out.print(message); | |||||
| userStr = Util.myInput.nextLine(); | |||||
| correct = userStr.length() >= minLenght && userStr.length() <= maxLenght; | |||||
| if (!correct) { | |||||
| System.out.printf("Longitud minima %d, maxima %d \n", minLenght, maxLenght); | |||||
| Util.pause(); | |||||
| } | |||||
| } while (!correct); | |||||
| return userStr; | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @return | |||||
| */ | |||||
| public static int[] validateArray() { | |||||
| System.out.println("***VALIDACION DE UN ARRAY DE ENTEROS***"); | |||||
| System.out.println("Introduce la longitud del array"); | |||||
| int userInt; | |||||
| int array[] = new int[myInput.nextInt()]; | |||||
| try { | |||||
| String message = ("Introduce un numero para el array "); | |||||
| for (int i = 0; i < array.length; i++) { | |||||
| int userInt1 = 0; | |||||
| do { | |||||
| System.out.print(message); | |||||
| try { | |||||
| userInt1 = Integer.parseInt(Util.myInput.nextLine()); | |||||
| Util.correct = true; | |||||
| Util.pause(); | |||||
| } catch (NumberFormatException e) { | |||||
| System.out.println("Error: El input no es un integer"); | |||||
| Util.pause(); | |||||
| Util.correct = false; | |||||
| } | |||||
| } while (!Util.correct); | |||||
| userInt = userInt1; | |||||
| array[i] = (userInt + (i + 1)); | |||||
| } | |||||
| // estos errores no tendrian que estar controlados porque son evitables | |||||
| } catch (Exception e) { | |||||
| System.out.println("El dato tiene que ser de tipo integer"); | |||||
| } | |||||
| return array; | |||||
| } | |||||
| // min y max numeros aleatorios a generar | |||||
| public static void fillArrayRandom(int[] array, int min, int max) { | |||||
| for (int i = 0; i < array.length; i++) { | |||||
| array[i] = random.nextInt(max - min + 1) + min; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @param date | |||||
| * @return date formated with hour minute and seconds | |||||
| */ | |||||
| public String dateFrmTime(LocalDate date) { | |||||
| DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); | |||||
| return dtf.format(date); | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @param date | |||||
| * @return date formatted only with year | |||||
| */ | |||||
| public static String dateFrmYear(LocalDate date) { | |||||
| DateTimeFormatter dt = DateTimeFormatter.ofPattern("dd/MM/yyyy"); | |||||
| return dt.format(date); | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @param date | |||||
| * @return date formatted only with year | |||||
| */ | |||||
| public static String dateFrmYear(Date date) { | |||||
| if (date != null) { | |||||
| SimpleDateFormat dt = new SimpleDateFormat("dd/MM/yyyy"); | |||||
| return dt.format(date); | |||||
| } | |||||
| return null; | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @param date gregorian calendar | |||||
| * @return date formatted only with year | |||||
| */ | |||||
| public static String dateFrmYear(GregorianCalendar date) { | |||||
| if (date != null) { | |||||
| try { | |||||
| SimpleDateFormat dt = new SimpleDateFormat("dd/MM/yyyy"); | |||||
| dt.setCalendar(date); | |||||
| return dt.format(date.getTime()); | |||||
| } catch (StackOverflowError sf) { | |||||
| sf.printStackTrace(); | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @return a class that represents an immutable universally unique identifier | |||||
| * (UUID). A UUID represents a 128-bit value. | |||||
| */ | |||||
| public static String generateString() { | |||||
| String uuid = UUID.randomUUID().toString(); | |||||
| return uuid; | |||||
| } | |||||
| public static String checkAnswer(String option1, String option2) { | |||||
| String user = ""; | |||||
| do { | |||||
| System.out.println("Please write these two avaliable options " + (option1) + " " + option2); | |||||
| user = Util.myInput.nextLine(); | |||||
| if (user.equalsIgnoreCase(option1)) { | |||||
| return option1; | |||||
| } else if (user.equalsIgnoreCase(option2)) { | |||||
| return option2; | |||||
| } else { | |||||
| System.out | |||||
| .println("Your answer must match with the avaliable options.\nPlease write again your option."); | |||||
| correct = false; | |||||
| } | |||||
| } while (correct = true); | |||||
| return "Error"; | |||||
| } | |||||
| public static char letraNIF(int dni) { | |||||
| String tabla = "TRWAGMYFPDXBNJZSQVHLCKE"; | |||||
| int modulo = dni % 23; | |||||
| return tabla.charAt(modulo); | |||||
| } | |||||
| public static boolean validarNIF(String nif) { | |||||
| if (nif != null && nif.length() >= 2) { | |||||
| nif = nif.toUpperCase(); | |||||
| StringBuilder dniString = new StringBuilder(); | |||||
| // Cogemos como letra el último caracter del NIF | |||||
| char letra = nif.charAt(nif.length() - 1); | |||||
| char c; | |||||
| for (int i = 0; i < nif.length(); i++) { | |||||
| // Si es un dígito lo añadimos a dniString | |||||
| c = nif.charAt(i); | |||||
| if (Character.isDigit(c)) { | |||||
| dniString.append(c); | |||||
| } | |||||
| } | |||||
| return !dniString.toString().equals("") && letra == letraNIF(Integer.parseInt(dniString.toString())); | |||||
| } | |||||
| return false; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,170 @@ | |||||
| package Lib; | |||||
| import java.util.Formatter; | |||||
| public class strM { | |||||
| public static char charAt(String a) { | |||||
| char result = 'a'; | |||||
| // Returns the character at the specified index position. | |||||
| for (int i = 0; i < a.length(); i++) { | |||||
| result = (a.charAt(i)); | |||||
| } | |||||
| return result; | |||||
| } | |||||
| public static String replace(String str, char searchChar, char newChar) { | |||||
| // The replace() method searches a string for a specified character, and returns | |||||
| // a new string where the specified character(s) are replaced. | |||||
| return (str.replace(searchChar, newChar)); | |||||
| } | |||||
| public static int indexOf(String str, char character) { | |||||
| // The indexOf() method returns the position of the first occurrence of | |||||
| // specified character(s) in a string. | |||||
| return (str.indexOf(character)); | |||||
| } | |||||
| public static boolean startsWith(String str, String searchString) { | |||||
| return (str.startsWith(searchString)); | |||||
| } | |||||
| public static boolean endsWith(String str, String searchString) { | |||||
| return (str.endsWith(searchString)); | |||||
| } | |||||
| public static void split(String str, String searchString, int numberOfArrays) { | |||||
| // The string split() method breaks a given string around matches of the given | |||||
| // regular expression | |||||
| String[] arrStr = (str.split(searchString, numberOfArrays)); | |||||
| for (String a : arrStr) | |||||
| System.out.print(a + "\n"); | |||||
| // System.out.println(); | |||||
| } | |||||
| public static int compareTo(String str, String anotherString) { | |||||
| // System.out.println(str.compareTo(anotherString)); | |||||
| // Returns: An int value: 0 if the string is equal to the other string. | |||||
| // < 0 if the string is lexicographically less than the other string | |||||
| // > 0 if the string is lexicographically greater than the other string (more | |||||
| // characters) | |||||
| return (str.compareTo(anotherString)); | |||||
| } | |||||
| public static int compareToIngnoreCase(String str, String anotherString) { | |||||
| // Compare two strings, ignoring lower case and upper case differences: | |||||
| return (str.compareToIgnoreCase(anotherString)); | |||||
| } | |||||
| public static boolean contains(String str, String searchString) { | |||||
| // The contains() method checks whether a string contains a sequence of | |||||
| // characters. | |||||
| // Returns true if the characters exist and false if not. | |||||
| return (str.contains(searchString)); | |||||
| } | |||||
| public static boolean contentEquals(String str, String compareString) { | |||||
| // The contentEquals() method searches a string to find out if it contains the | |||||
| // exact same sequence of characters in the specified string or StringBuffer. | |||||
| return (str.contentEquals(compareString)); | |||||
| } | |||||
| public static String concat(String str, String addString) { | |||||
| return (str.concat(addString)); | |||||
| } | |||||
| public static String copyValueOf(char[] myChar, String removeSpaces, int offset, int count) { | |||||
| return (removeSpaces.copyValueOf(myChar, offset, count)); | |||||
| } | |||||
| public static boolean isEmpty(String str) { | |||||
| return (str.isEmpty()); | |||||
| } | |||||
| public static String trim(String str) { | |||||
| // trim() The trim() method removes whitespace from both ends of a string and | |||||
| // returns a new string, without modifying the original string. Whitespace in | |||||
| // this context is all the whitespace characters (space, tab, no-break space, | |||||
| // etc.) | |||||
| return (str.trim()); | |||||
| } | |||||
| public static boolean equals(String str, String anotherObject) { | |||||
| // The Java String class equals() method compares the two given strings based on | |||||
| // the content of the string. If any character is not matched, it returns false. | |||||
| // If all characters are matched, it returns true. The String equals() method | |||||
| // overrides the equals() method of the Object class. | |||||
| return (str.equals(anotherObject)); | |||||
| } | |||||
| public static boolean equalsIgnoreCase(String str, String anotherObject) { | |||||
| return (str.equalsIgnoreCase(anotherObject)); | |||||
| } | |||||
| public static String substring(String str, int offset, int count) { | |||||
| // A part of String is called substring. In other words, substring is a subset | |||||
| // of another String. Java String class provides the built-in substring() method | |||||
| // that extract a substring from the given string by using the index values | |||||
| // passed as an argument. | |||||
| // In case of substring() method startIndex is inclusive and endIndex is | |||||
| // exclusive. | |||||
| return (str.substring(offset, count)); | |||||
| } | |||||
| public static int indexOf(String str, int indice) { | |||||
| // The indexOf() method is used in Java to retrieve the index position at which | |||||
| // a particular character or substring appears in another string. You can use a | |||||
| // second argument to start your search after a particular index number in the | |||||
| // string. If the specified letter or letters cannot be found, indexOf() returns | |||||
| // -1 | |||||
| return (str.indexOf(str, indice)); | |||||
| } | |||||
| public static int lastIndexOf(String str, String searchString) { | |||||
| return (str.lastIndexOf(searchString)); | |||||
| } | |||||
| public static int lastIndexOf(String str, int searchIndex) { | |||||
| return (str.lastIndexOf(searchIndex)); | |||||
| } | |||||
| public static String replace(String str, String searchString, String newString) { | |||||
| return (str.replace(searchString, newString)); | |||||
| } | |||||
| public static String replaceAll(String str, String searchString, String newString) { | |||||
| return (str.replaceAll(searchString, newString)); | |||||
| // "[^abc]" [0 - 9] | |||||
| // System.out.println(s.replaceAll("[au]", "o")); | |||||
| // System.out.println(s.replaceAll("perro|gato", "animal")); | |||||
| // System.out.println(s.replaceAll("e.a", "illa")); | |||||
| // System.out.println(s.replaceAll("^Hola", "Te saludo")); | |||||
| // System.out.println(s.replaceAll("Hola$", "Te saludo")); | |||||
| // System.out.println(s.replaceAll("\\d", "*")); | |||||
| // System.out.println(s.replaceAll("\\s", "")); | |||||
| // System.out.println(s.replaceAll("\\s+", " ")); | |||||
| } | |||||
| public static String valueOf(String str, int convert) { | |||||
| // The java string valueOf() method converts different types of values into | |||||
| // string. By the help of string valueOf() method, you can convert int to | |||||
| // string, long to string, boolean to string, character to string, float to | |||||
| // string, double to string, object to string and char array to string. | |||||
| return (str = String.valueOf(convert)); | |||||
| } | |||||
| public static String stringFormat(Object args) { | |||||
| // The java string format() method returns the formatted string by given locale, | |||||
| // format and arguments. | |||||
| return new Formatter().format("%s", args).toString(); | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,21 @@ | |||||
| package com.primerEjemplo; | |||||
| import com.primerEjemplo.Modelo.Servicio.Servicio; | |||||
| import org.springframework.context.support.ClassPathXmlApplicationContext; | |||||
| import java.io.IOException; | |||||
| public class App { | |||||
| public static void main(String[] args) throws IOException { | |||||
| ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext("beans.xml"); | |||||
| // Servicio servicio = new Servicio(); | |||||
| // servicio = appContext.getBean(Servicio.class); | |||||
| Tienda tienda = appContext.getBean(Tienda.class); | |||||
| appContext.close(); | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,18 @@ | |||||
| package com.primerEjemplo.Modelo.Interfaz; | |||||
| import com.primerEjemplo.Modelo.Libro; | |||||
| import java.util.List; | |||||
| public interface IServicioConsulta { | |||||
| List<Libro> ejecutarLibro(); | |||||
| IServicioConsulta cualquierCategoria(String... generos); | |||||
| IServicioConsulta categorias(String... generos); | |||||
| IServicioConsulta anyo(String year); | |||||
| IServicioConsulta porPeriodoAnyos(String from, String to); | |||||
| IServicioConsulta buscarTitulo(String titulo); | |||||
| } | |||||
| @ -0,0 +1,17 @@ | |||||
| package com.primerEjemplo.Modelo.Interfaz; | |||||
| import com.primerEjemplo.Modelo.Libro; | |||||
| import java.io.FileNotFoundException; | |||||
| import java.util.Collection; | |||||
| import java.util.List; | |||||
| public interface IServicioLibro { | |||||
| Libro buscarLibro(String isbn) throws FileNotFoundException; | |||||
| boolean anyadirLibro(Libro libro); | |||||
| boolean venderLibro(String isbn); | |||||
| String mostrarLibroResumen(String isbn); | |||||
| Collection<Libro> mostrarLibrosResumen(); | |||||
| Collection<Libro> mostrarLibros(); | |||||
| } | |||||
| @ -0,0 +1,29 @@ | |||||
| package com.primerEjemplo.Modelo.Interfaz; | |||||
| import com.primerEjemplo.Modelo.Libro; | |||||
| import com.primerEjemplo.Modelo.ParserLibros; | |||||
| import java.io.File; | |||||
| import java.io.FileNotFoundException; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| public class InterfazDatos { | |||||
| public static List<Libro> getDatos() throws FileNotFoundException { | |||||
| List<Libro> libros; | |||||
| File file = new File("/home/michael/Documents/SpringProjects/SpringCore/Libros/src/main/resources/libros.json"); | |||||
| ParserLibros parserLibros = new ParserLibros(file); | |||||
| if (parserLibros.startParser()) { | |||||
| System.out.println("Datos Parseados"); | |||||
| libros = parserLibros.getLibros(); | |||||
| } else { | |||||
| System.out.println("Error al parsear"); | |||||
| return null; | |||||
| } | |||||
| return libros; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,164 @@ | |||||
| package com.primerEjemplo.Modelo; | |||||
| import com.github.javafaker.Faker; | |||||
| import java.io.File; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.time.LocalDate; | |||||
| import java.time.format.DateTimeFormatter; | |||||
| import java.util.Calendar; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| import java.util.Objects; | |||||
| public class Libro { | |||||
| private final String isbn; | |||||
| private final String titulo; | |||||
| private final long numeroPaginas; | |||||
| private final String fechaPublicacion; | |||||
| private final String url; | |||||
| private final String descripcionCorta; | |||||
| private final String descripcionLarga; | |||||
| private final String estado; | |||||
| private final List<String> autores; | |||||
| private final List<String> categorias; | |||||
| private String anyo; | |||||
| private LocalDate localDate; | |||||
| public Libro(String isbn, String titulo, long numeroPaginas, String fechaPublicacion, String url, String descripcionCorta, String descripcionLarga, String estado, List<String> autores, List<String> categorias) { | |||||
| this.isbn = isbn; | |||||
| this.titulo = titulo; | |||||
| this.numeroPaginas = numeroPaginas; | |||||
| this.fechaPublicacion = conversionFecha(fechaPublicacion); | |||||
| this.url = url; | |||||
| this.descripcionCorta = descripcionCorta; | |||||
| this.descripcionLarga = descripcionLarga; | |||||
| this.estado = estado; | |||||
| this.autores = autores; | |||||
| this.categorias = categorias; | |||||
| } | |||||
| public String getIsbn() { | |||||
| return isbn; | |||||
| } | |||||
| public String getTitulo() { | |||||
| return titulo; | |||||
| } | |||||
| public long getNumeroPaginas() { | |||||
| return numeroPaginas; | |||||
| } | |||||
| public String getFechaPublicacion() { | |||||
| return fechaPublicacion; | |||||
| } | |||||
| public String getUrl() { | |||||
| return url; | |||||
| } | |||||
| public String getDescripcionCorta() { | |||||
| return descripcionCorta; | |||||
| } | |||||
| public String getDescripcionLarga() { | |||||
| return descripcionLarga; | |||||
| } | |||||
| public String getEstado() { | |||||
| return estado; | |||||
| } | |||||
| public List<String> getAutores() { | |||||
| return autores; | |||||
| } | |||||
| public List<String> getCategorias() { | |||||
| return categorias; | |||||
| } | |||||
| public String conversionFecha(String fecha) { | |||||
| if (fecha == null) { | |||||
| return generarFecha(); | |||||
| } | |||||
| DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS"); | |||||
| DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("dd-MM-yyy"); | |||||
| localDate = LocalDate.parse(fecha, inputFormatter); | |||||
| anyo = String.valueOf(localDate.getYear()); | |||||
| return outputFormatter.format(localDate); | |||||
| } | |||||
| public String getAnyo(){ | |||||
| if (anyo == null){ | |||||
| anyo = String.valueOf(localDate.getYear()); | |||||
| } | |||||
| return anyo; | |||||
| } | |||||
| public String generarFecha(){ | |||||
| Faker faker = new Faker(); | |||||
| Calendar calendar = Calendar.getInstance(); | |||||
| calendar.set(Calendar.MONTH,11); | |||||
| calendar.set(Calendar.DATE, 5); | |||||
| calendar.set(Calendar.YEAR,2009); | |||||
| Calendar calendar1 = Calendar.getInstance(); | |||||
| calendar1.set(Calendar.MONTH,11); | |||||
| calendar1.set(Calendar.DATE, 5); | |||||
| calendar1.set(Calendar.YEAR,2009); | |||||
| Date date = faker.date().between(calendar.getTime(),calendar1.getTime()); | |||||
| SimpleDateFormat ft = new SimpleDateFormat ("yyyy-MM-dd"); | |||||
| String fechaFormateada = ft.format(date); | |||||
| localDate = LocalDate.parse(fechaFormateada); | |||||
| anyo = String.valueOf(localDate.getYear()); | |||||
| return fechaFormateada; | |||||
| } | |||||
| @Override | |||||
| public boolean equals(Object o) { | |||||
| if (this == o) return true; | |||||
| if (o == null || getClass() != o.getClass()) return false; | |||||
| Libro libro = (Libro) o; | |||||
| return Objects.equals(isbn, libro.isbn) && Objects.equals(fechaPublicacion, libro.fechaPublicacion) && Objects.equals(estado, libro.estado) && Objects.equals(categorias, libro.categorias); | |||||
| } | |||||
| @Override | |||||
| public int hashCode() { | |||||
| return Objects.hash(isbn, fechaPublicacion, estado, categorias); | |||||
| } | |||||
| public String printarResumenLibro(){ | |||||
| return "Libro{" + | |||||
| "isbn='" + isbn + '\'' + | |||||
| ", titulo='" + titulo + '\'' + | |||||
| ", numeroPaginas=" + numeroPaginas + | |||||
| ", fechaPublicacion='" + fechaPublicacion + '\'' + | |||||
| ", estado='" + estado + '\'' + | |||||
| ", autores=" + autores + | |||||
| ", categorias='" + categorias + '\'' + | |||||
| '}'; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return "Libro{" + | |||||
| "isbn='" + isbn + '\'' + | |||||
| ", titulo='" + titulo + '\'' + | |||||
| ", numeroPaginas=" + numeroPaginas + | |||||
| ", fechaPublicacion='" + fechaPublicacion + '\'' + | |||||
| ", url='" + url + '\'' + | |||||
| ", descripcionCorta='" + descripcionCorta + '\'' + | |||||
| ", descripcionLarga='" + descripcionLarga + '\'' + | |||||
| ", estado='" + estado + '\'' + | |||||
| ", autores=" + autores + | |||||
| ", categorias='" + categorias + '\'' + | |||||
| '}'; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,106 @@ | |||||
| package com.primerEjemplo.Modelo; | |||||
| import com.github.javafaker.Faker; | |||||
| import org.json.JSONArray; | |||||
| import org.json.JSONException; | |||||
| import org.json.JSONObject; | |||||
| import org.json.JSONTokener; | |||||
| import java.io.*; | |||||
| import java.nio.charset.StandardCharsets; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Calendar; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| public class ParserLibros { | |||||
| private List<Libro> libros; | |||||
| private final InputStream inputStream; | |||||
| private Faker faker = new Faker(); | |||||
| public ParserLibros(File file) throws FileNotFoundException { | |||||
| inputStream = new FileInputStream(file); | |||||
| } | |||||
| public boolean startParser() { | |||||
| List<String> autores; | |||||
| List<String> categorias; | |||||
| libros = new ArrayList<>(); | |||||
| try { | |||||
| int size = inputStream.available(); | |||||
| byte[] buffer = new byte[size]; | |||||
| inputStream.read(buffer); | |||||
| inputStream.close(); | |||||
| String json = new String(buffer, StandardCharsets.UTF_8); | |||||
| JSONTokener jsonTokener = new JSONTokener(json); | |||||
| JSONArray jsonArray = new JSONArray(jsonTokener); | |||||
| libros = new ArrayList<>(); | |||||
| for (int i = 0; i < jsonArray.length(); i++) { | |||||
| JSONObject jsonObject = jsonArray.getJSONObject(i); | |||||
| String titulo = jsonObject.getString("title"); | |||||
| long numeroPaginas = jsonObject.getLong("pageCount"); | |||||
| String estado = jsonObject.getString("status"); | |||||
| //Variables que no pueden estar | |||||
| String isbn; | |||||
| String descripcionCorta; | |||||
| String descripcionLarga; | |||||
| String url; | |||||
| String fechaPublicacion; | |||||
| try { | |||||
| isbn = jsonObject.getString("isbn"); | |||||
| descripcionCorta = jsonObject.getString("shortDescription"); | |||||
| descripcionLarga = jsonObject.getString("longDescription"); | |||||
| url = jsonObject.getString("thumbnailUrl"); | |||||
| fechaPublicacion = jsonObject.getString("publishedDate"); | |||||
| } catch (JSONException j) { | |||||
| descripcionCorta = null; | |||||
| descripcionLarga = null; | |||||
| url = null; | |||||
| isbn = faker.number().digits(10); | |||||
| fechaPublicacion = null; | |||||
| } | |||||
| //Rellenamos la matriz de autores | |||||
| JSONArray matrizAutores = jsonObject.getJSONArray("authors"); | |||||
| autores = new ArrayList<>(matrizAutores.length()); | |||||
| for (int j = 0; j < matrizAutores.length(); j++) { | |||||
| String autoresRecogidos = matrizAutores.getString(j); | |||||
| autores.add(autoresRecogidos); | |||||
| } | |||||
| //Rellenamos la matriz de categorias | |||||
| JSONArray matrizCategorias = jsonObject.getJSONArray("categories"); | |||||
| categorias = new ArrayList<>(matrizCategorias.length()); | |||||
| for (int j = 0; j < matrizCategorias.length(); j++) { | |||||
| String categoriasRecogidas = matrizCategorias.getString(j); | |||||
| categorias.add(categoriasRecogidas); | |||||
| } | |||||
| String fechaFormateada = null; | |||||
| if (fechaPublicacion != null) { | |||||
| fechaFormateada = fechaPublicacion.substring(0, 23); | |||||
| } | |||||
| libros.add(new Libro(isbn, titulo, numeroPaginas, fechaFormateada, url, descripcionCorta, descripcionLarga, estado, autores, categorias)); | |||||
| } | |||||
| return true; | |||||
| } catch (IOException e) { | |||||
| e.printStackTrace(); | |||||
| } | |||||
| return false; | |||||
| } | |||||
| public List<Libro> getLibros() { | |||||
| return libros; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,84 @@ | |||||
| package com.primerEjemplo.Modelo.Servicio; | |||||
| import com.primerEjemplo.Modelo.Interfaz.IServicioConsulta; | |||||
| import com.primerEjemplo.Modelo.Interfaz.IServicioLibro; | |||||
| import com.primerEjemplo.Modelo.Libro; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import java.time.LocalDate; | |||||
| import java.util.Arrays; | |||||
| import java.util.List; | |||||
| import java.util.function.Predicate; | |||||
| public class ImplementaIntefazServicioConsultas implements IServicioConsulta { | |||||
| Predicate<Libro> libroPredicate; | |||||
| @Autowired | |||||
| IServicioLibro iServicioLibro; | |||||
| public ImplementaIntefazServicioConsultas() { | |||||
| libroPredicate = null; | |||||
| } | |||||
| @Override | |||||
| public List<Libro> ejecutarLibro() { | |||||
| // return iServicioLibro.mostrarLibros().stream().filter(libroPredicate).toList(); | |||||
| return iServicioLibro.mostrarLibrosResumen().stream().filter(libroPredicate).toList(); | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @param categorias busca la primera categoria que encuentra similar | |||||
| * @return la interfaz recargada con la nueva logica dentro del predicate que servira al ejecutar el libro. | |||||
| */ | |||||
| @Override | |||||
| public IServicioConsulta cualquierCategoria(String... categorias) { | |||||
| Predicate<Libro> cualquierGenero = libro -> Arrays.stream(categorias).anyMatch(libro.getCategorias()::contains); | |||||
| libroPredicate = (libroPredicate == null) ? cualquierGenero : libroPredicate.and(cualquierGenero); | |||||
| return this; | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @param categorias busca todas las categorias que encuentra similar | |||||
| * @return la interfaz recargada con la nueva logica dentro del predicate que servira al ejecutar el libro. | |||||
| */ | |||||
| @Override | |||||
| public IServicioConsulta categorias(String... categorias) { | |||||
| Predicate<Libro> categoriaEspecifica = libro -> Arrays.stream(categorias).allMatch(libro.getCategorias()::contains); | |||||
| libroPredicate = (libroPredicate == null) ? categoriaEspecifica : libroPredicate.and(categoriaEspecifica); | |||||
| return this; | |||||
| } | |||||
| @Override | |||||
| public IServicioConsulta anyo(String year) { | |||||
| Predicate<Libro> anyo = libro -> libro.getFechaPublicacion().contains(year); | |||||
| libroPredicate = (libroPredicate == null) ? anyo : libroPredicate.and(anyo); | |||||
| return this; | |||||
| } | |||||
| @Override | |||||
| public IServicioConsulta porPeriodoAnyos(String from, String to) { | |||||
| Predicate<Libro> pBetweenYears = (libro -> { | |||||
| LocalDate fromYear = LocalDate.of(Integer.parseInt(from), 1, 1); | |||||
| LocalDate toYear = LocalDate.of(Integer.parseInt(to), 1, 3); | |||||
| LocalDate filmYear = LocalDate.of(Integer.parseInt(libro.getAnyo()), 1, 2); | |||||
| return filmYear.isAfter(fromYear) && filmYear.isBefore(toYear); | |||||
| }); | |||||
| libroPredicate = (libroPredicate == null) ? pBetweenYears: libroPredicate.and(pBetweenYears); | |||||
| return this; | |||||
| } | |||||
| @Override | |||||
| public IServicioConsulta buscarTitulo(String titulo) { | |||||
| Predicate<Libro> tituloEncontrado = (libro -> libro.getTitulo().toLowerCase().contains(titulo.toLowerCase())); | |||||
| libroPredicate = (libroPredicate == null) ? tituloEncontrado : libroPredicate.and(tituloEncontrado); | |||||
| return this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,79 @@ | |||||
| package com.primerEjemplo.Modelo.Servicio; | |||||
| import com.primerEjemplo.Modelo.Interfaz.IServicioLibro; | |||||
| import com.primerEjemplo.Modelo.Interfaz.InterfazDatos; | |||||
| import com.primerEjemplo.Modelo.Libro; | |||||
| import com.primerEjemplo.Modelo.ParserLibros; | |||||
| import java.io.File; | |||||
| import java.io.FileNotFoundException; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Collection; | |||||
| import java.util.List; | |||||
| public class ImplementaIntefazServicioGeneral implements IServicioLibro { | |||||
| private final List<Libro> libros; | |||||
| private Libro libro; | |||||
| public ImplementaIntefazServicioGeneral() throws FileNotFoundException { | |||||
| libros = InterfazDatos.getDatos(); | |||||
| } | |||||
| @Override | |||||
| public Libro buscarLibro(String isbn) { | |||||
| libro = iterarLibros(isbn); | |||||
| return libro; | |||||
| } | |||||
| @Override | |||||
| public boolean venderLibro(String isbn) { | |||||
| libro = iterarLibros(isbn); | |||||
| try{ | |||||
| if (libro.getEstado().equalsIgnoreCase("publish")){ | |||||
| return libros.remove(libro); | |||||
| } | |||||
| }catch (NullPointerException n){ | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| } | |||||
| @Override | |||||
| public String mostrarLibroResumen(String isbn) { | |||||
| libro = iterarLibros(isbn); | |||||
| if (libro == null){ | |||||
| System.out.println("Error"); | |||||
| } | |||||
| System.out.println(libro.printarResumenLibro()); | |||||
| return isbn; | |||||
| } | |||||
| @Override | |||||
| public Collection<Libro> mostrarLibrosResumen() { | |||||
| return libros; | |||||
| } | |||||
| @Override | |||||
| public Collection<Libro> mostrarLibros() { | |||||
| return libros; | |||||
| } | |||||
| @Override | |||||
| public boolean anyadirLibro(Libro libro) { | |||||
| return libros.add(libro); | |||||
| } | |||||
| public Libro iterarLibros(String isbn){ | |||||
| for (Libro value : libros) { | |||||
| if (value.getIsbn().equalsIgnoreCase(isbn)) { | |||||
| libro = value; | |||||
| return libro; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,77 @@ | |||||
| package com.primerEjemplo.Modelo.Servicio; | |||||
| import com.primerEjemplo.Modelo.Interfaz.IServicioConsulta; | |||||
| import com.primerEjemplo.Modelo.Libro; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.Collection; | |||||
| import java.util.List; | |||||
| import java.util.stream.Collectors; | |||||
| @Service | |||||
| public class Servicio { | |||||
| @Autowired | |||||
| private ImplementaIntefazServicioGeneral implementaIntefaz; | |||||
| @Autowired | |||||
| private IServicioConsulta iServicioConsulta ; | |||||
| public Servicio() { | |||||
| } | |||||
| //CONSULTAS ESPECIFICAS POR CADALIBRO | |||||
| public List<String> mostrarCategorias(){ | |||||
| List<String> categorias; | |||||
| categorias = implementaIntefaz.mostrarLibros().stream().map(Libro::getCategorias). | |||||
| flatMap(Collection::stream).distinct().sorted().collect(Collectors.toList()); | |||||
| return categorias; | |||||
| } | |||||
| public List<Libro> mostrarCategorias(String... generos){ | |||||
| return iServicioConsulta.cualquierCategoria(generos).ejecutarLibro(); | |||||
| } | |||||
| public List<Libro> mostrarPorCategoria(String... genero){ | |||||
| return iServicioConsulta.categorias(genero).ejecutarLibro(); | |||||
| } | |||||
| public List<Libro> encontrarPorFecha(String year){ | |||||
| return iServicioConsulta.anyo(year).ejecutarLibro(); | |||||
| } | |||||
| public List<Libro> encontrarPorPeriodo(String from, String till){ | |||||
| return iServicioConsulta.porPeriodoAnyos(from,till).ejecutarLibro(); | |||||
| } | |||||
| public List<Libro> encontrarPorTitulo(String titulo){ | |||||
| return iServicioConsulta.buscarTitulo(titulo).ejecutarLibro(); | |||||
| } | |||||
| //BUSQUEDA GENERAL | |||||
| public List<Libro> mostrarLibros(){ | |||||
| return (List<Libro>) implementaIntefaz.mostrarLibros(); | |||||
| } | |||||
| public String mostrarResumenLibros(String isbn ){ | |||||
| return implementaIntefaz.mostrarLibroResumen(isbn); | |||||
| } | |||||
| public boolean anyadirLibro(Libro libro){ | |||||
| return implementaIntefaz.anyadirLibro(libro); | |||||
| } | |||||
| public boolean venderLibro(String isbn){ | |||||
| return implementaIntefaz.venderLibro(isbn); | |||||
| } | |||||
| public Libro buscarLibro(String isbn){ | |||||
| return implementaIntefaz.buscarLibro(isbn); | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,84 @@ | |||||
| package com.primerEjemplo; | |||||
| import Lib.Control; | |||||
| import Lib.Util; | |||||
| import com.primerEjemplo.Modelo.Libro; | |||||
| import com.primerEjemplo.Modelo.Servicio.Servicio; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import java.util.Scanner; | |||||
| public class Tienda { | |||||
| private final Servicio servicio; | |||||
| @Autowired | |||||
| public Tienda(Servicio servicio) { | |||||
| this.servicio = servicio; | |||||
| menuPrincipal(); | |||||
| } | |||||
| public void menuPrincipal(){ | |||||
| Scanner scanner = Util.myInput; | |||||
| String[] opciones ={"Salir", "Mostrar Todos los libros", "Mostrar categorias", "Mostrar por categoria", "Mostrar por ISBN", "Mostrar por titulo", "Mostrar por periodo", "Comprar libro",}; | |||||
| String titulo = "BIENVENIDO A NUESTRA TIENDA"; | |||||
| int opcion = Control.menuGenerator(0,titulo,opciones); | |||||
| String respuesta; | |||||
| switch (opcion) { | |||||
| case 0 -> System.out.println("HASTA PRONTO !!"); | |||||
| case 1 -> servicio.mostrarLibros().forEach(System.out::println); | |||||
| case 2 -> servicio.mostrarCategorias().forEach(System.out::println); | |||||
| case 3 -> { | |||||
| System.out.println("Introduce el catalgo del libro"); | |||||
| respuesta = scanner.nextLine(); | |||||
| servicio.mostrarPorCategoria(respuesta).forEach(System.out::println); | |||||
| } | |||||
| case 4 -> { | |||||
| System.out.println("Introduce el ISBN del libro"); | |||||
| respuesta = scanner.nextLine(); | |||||
| System.out.println(servicio.buscarLibro(respuesta)); | |||||
| } | |||||
| case 5 -> { | |||||
| System.out.println("Introduce el titulo del libro"); | |||||
| respuesta = scanner.nextLine(); | |||||
| servicio.encontrarPorTitulo(respuesta).forEach(System.out::println); | |||||
| } | |||||
| case 6 -> { | |||||
| System.out.println("Introduce el desde que anyo quieres filtrar los libros "); | |||||
| respuesta = scanner.nextLine(); | |||||
| System.out.println("Introduce el anyo fin que quieres filtrar los libros"); | |||||
| String respuesta1 = scanner.nextLine(); | |||||
| servicio.encontrarPorPeriodo(respuesta, respuesta1).forEach(System.out::println); | |||||
| } | |||||
| case 7 -> { | |||||
| System.out.println("Introduce el isbn del libro que deseas seleccionar"); | |||||
| respuesta = scanner.nextLine(); | |||||
| System.out.println(servicio.buscarLibro(respuesta)); | |||||
| if (servicio.venderLibro(respuesta)){ | |||||
| System.out.println("LIBRO VENDIDO EXITOSAMENTE"); | |||||
| }else{ | |||||
| System.out.println("LO SENTIMOS EL LIBRO NO ESTA DISPONIBLE"); | |||||
| } | |||||
| } | |||||
| } | |||||
| Util.pause(); | |||||
| Util.cleanScreen(); | |||||
| if(Control.one("Quieres volver al menu principal s/n",'s')){ | |||||
| menuPrincipal(); | |||||
| }else{ | |||||
| System.out.println("Hasta luego !!"); | |||||
| } | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,21 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <beans xmlns="http://www.springframework.org/schema/beans" | |||||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
| xmlns:context="http://www.springframework.org/schema/context" | |||||
| xsi:schemaLocation="http://www.springframework.org/schema/beans | |||||
| http://www.springframework.org/schema/beans/spring-beans.xsd | |||||
| http://www.springframework.org/schema/context | |||||
| http://www.springframework.org/schema/context/spring-context-4.3.xsd"> | |||||
| <context:annotation-config /> | |||||
| <bean id="implementaIntefazServicioConsultas" class="com.primerEjemplo.Modelo.Servicio.ImplementaIntefazServicioConsultas"/> | |||||
| <bean id="implementaIntefazServicioGeneral" class="com.primerEjemplo.Modelo.Servicio.ImplementaIntefazServicioGeneral"/> | |||||
| <bean id="tienda" class="com.primerEjemplo.Tienda"/> | |||||
| <bean id="servicio" class="com.primerEjemplo.Modelo.Servicio.Servicio"/> | |||||
| </beans> | |||||
| @ -0,0 +1,3 @@ | |||||
| file.path=classpath:imdb_data.csv | |||||
| file.csv.separator=; | |||||
| file.csv.list_separator=, | |||||
| @ -0,0 +1,3 @@ | |||||
| # | |||||
| #Thu Nov 24 11:27:55 CET 2022 | |||||
| com.primerEjemplo.Modelo.Servicio.Servicio=org.springframework.stereotype.Component | |||||
| @ -0,0 +1,21 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <beans xmlns="http://www.springframework.org/schema/beans" | |||||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
| xmlns:context="http://www.springframework.org/schema/context" | |||||
| xsi:schemaLocation="http://www.springframework.org/schema/beans | |||||
| http://www.springframework.org/schema/beans/spring-beans.xsd | |||||
| http://www.springframework.org/schema/context | |||||
| http://www.springframework.org/schema/context/spring-context-4.3.xsd"> | |||||
| <context:annotation-config /> | |||||
| <bean id="implementaIntefazServicioConsultas" class="com.primerEjemplo.Modelo.Servicio.ImplementaIntefazServicioConsultas"/> | |||||
| <bean id="implementaIntefazServicioGeneral" class="com.primerEjemplo.Modelo.Servicio.ImplementaIntefazServicioGeneral"/> | |||||
| <bean id="tienda" class="com.primerEjemplo.Tienda"/> | |||||
| <bean id="servicio" class="com.primerEjemplo.Modelo.Servicio.Servicio"/> | |||||
| </beans> | |||||
| @ -0,0 +1,3 @@ | |||||
| file.path=classpath:imdb_data.csv | |||||
| file.csv.separator=; | |||||
| file.csv.list_separator=, | |||||