first commit via Intellij

This commit is contained in:
aliihsansenel 2019-11-07 15:40:30 +01:00
parent a95abae632
commit b114a83a9b
37 changed files with 462 additions and 0 deletions

2
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# Default ignored files
/workspace.xml

14
.idea/compiler.xml Normal file
View File

@ -0,0 +1,14 @@
<?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="Project_1" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel target="8" />
</component>
</project>

View File

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="jsoup-1.12.1">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/jsoup-1.12.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

14
.idea/misc.xml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="13" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

2
Project_1.iml Normal file
View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />

Binary file not shown.

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>Parser</groupId>
<artifactId>jsoup</artifactId>
<version>1.12.1</version>
<description>POM was created from install:install-file</description>
</project>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>Parser</groupId>
<artifactId>jsoup</artifactId>
<versioning>
<release>1.12.1</release>
<versions>
<version>1.12.1</version>
</versions>
<lastUpdated>20191107132450</lastUpdated>
</versioning>
</metadata>

BIN
lib/jsoup-1.12.1.jar Normal file

Binary file not shown.

42
pom.xml
View File

@ -7,6 +7,48 @@
<groupId>ProLab</groupId>
<artifactId>Project_1</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>Parser</groupId>
<artifactId>jsoup</artifactId>
<version>1.12.1</version>
<scope>system</scope>
<systemPath>${basedir}/lib/jsoup-1.12.1.jar</systemPath>
</dependency>
<!-- <dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections-api</artifactId>
<version>10.0.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections</artifactId>
<version>10.0.0</version>
</dependency> -->
</dependencies>
</project>

View File

@ -0,0 +1,27 @@
import java.io.File;
import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
public class HTMLParser {
private Document doc = null;
private Elements links;
public HTMLParser(String local){
File input = new File(local);
try {
doc = Jsoup.parse(input, "UTF-8", "");
} catch (IOException e) {
e.printStackTrace();
}
links = doc.select("a[href]");
}
public String getTitle(){
return doc.title();
}
public Elements getElements(){
return links;
}
}

View File

@ -0,0 +1,13 @@
public class JUnitDemo {
private String name;
public JUnitDemo(String name) {
this.name = name;
}
public String getName() {
return name;
}
}

93
src/main/java/Main.java Normal file
View File

@ -0,0 +1,93 @@
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String peselStr;
System.out.print("Please enter your PESEL number: ");
peselStr = scan.nextLine();
int result = checkPesel(peselStr);
while(result != 0 ){
if(result == 1){
System.out.println("Pesel number must be 11 digit!");
}else if(result == 2){
System.out.println("Your entry is not number!");
} else {
System.out.println("Pesel number is not valid!");
}
System.out.print("Please enter valid 11 digit number: ");
peselStr = scan.nextLine();
result = checkPesel(peselStr);
}
System.out.println("Your input: " + peselStr + " satisfies conditions. You can continue...\n");
int pageIndex = 1;
HTMLParser parser;
for (pageIndex = 1; pageIndex < 2; pageIndex++){
parser = new HTMLParser("src/main/resources/page_" + String.valueOf(pageIndex) + ".html");
System.out.println("Title of the page: " + parser.getTitle());
System.out.println("Links in the page: ");
Elements links = parser.getElements();
for (Element link :links) {
System.out.println("URL: " + link.attr("href"));
System.out.println("Text of the link element: " + link.text());
System.out.println();
}
List<String> filtered = links.stream()
.map(link -> link.attr("href"))
.filter (url -> url.startsWith("http"))
.collect (Collectors.toList());
for (String linkStr :filtered) {
System.out.println("Out going URL: " + linkStr);
System.out.println();
}
}
}
public static int checkPesel(String peselStr){
try {
long pesel = Long.valueOf(peselStr);
if(peselStr.length() != 11){
return 1;
}else{
int checkSum = 0;
int lastDigit = (int)( pesel % 10);
pesel /= 10;
checkSum += 3 * (pesel % 10);
pesel /= 10;
checkSum += 1 * (pesel % 10);
pesel /= 10;
checkSum += 9 * (pesel % 10);
pesel /= 10;
checkSum += 7 * (pesel % 10);
pesel /= 10;
checkSum += 3 * (pesel % 10);
pesel /= 10;
checkSum += 1 * (pesel % 10);
pesel /= 10;
checkSum += 9 * (pesel % 10);
pesel /= 10;
checkSum += 7 * (pesel % 10);
pesel /= 10;
checkSum += 3 * (pesel % 10);
pesel /= 10;
checkSum += 1 * (pesel % 10);
/*System.out.println(checkSum);
System.out.println(lastDigit);*/
if((10 - (checkSum % 10)) % 10 != lastDigit ){
return 3;
}
}
}catch (NumberFormatException e){
return 2;
}
return 0;
}
}

13
src/main/resources/d.txt Normal file
View File

@ -0,0 +1,13 @@
mvn install:install-file \
-Dfile=${basedir}/lib/jsoup-1.12.1.jar \
-DgroupId=Parser \
-DartifactId=jsoup \
-Dversion=1.12.1 \
-Dpackaging=jar \
-DgeneratePom=true
mvn deploy:deploy-file -DgroupId=[GROUP] -DartifactId=[ARTIFACT] -Dversion=[VERS] -Durl=file:./lib/local-maven-repo/ -DrepositoryId=local-maven-repo -DupdateReleaseInfo=true -Dfile=[FILE_PATH]
mvn install:install-file -Dfile=./lib/jsoup-1.12.1.jar -DgroupId=Parser -DartifactId=jsoup -Dversion=1.12.1 -DlocalRepositoryPath=./lib/ -Dpackaging=jar

12
src/main/resources/iskelet.html Executable file
View File

@ -0,0 +1,12 @@
<html>
<head>
<title>Title</title>
<link rel="stylesheet" type="text/css" href="stil.css"></link>
<style>
</style>
</head>
<body>
</body>
</html>

18
src/main/resources/page_1.html Executable file
View File

@ -0,0 +1,18 @@
<html>
<head>
<title>First Page</title>
<link rel="stylesheet" type="text/css" href="stil.css"></link>
<style>
</style>
</head>
<body>
<a href="home">HomePage</a>
<a href="https://www.google.com">Google</a>
<a href="https://www.github.com">Github</a>
<a href="aboutus">About Us</a>
<a href="courses">Courses</a>
<a href="https://www.tureng.com">Tureng</a>
<a>link element without a href attribute this won't show up in program.</a>
</body>
</html>

12
src/main/resources/page_2.html Executable file
View File

@ -0,0 +1,12 @@
<html>
<head>
<title>Title</title>
<link rel="stylesheet" type="text/css" href="stil.css"></link>
<style>
</style>
</head>
<body>
</body>
</html>

12
src/main/resources/page_3.html Executable file
View File

@ -0,0 +1,12 @@
<html>
<head>
<title>Title</title>
<link rel="stylesheet" type="text/css" href="stil.css"></link>
<style>
</style>
</head>
<body>
</body>
</html>

12
src/main/resources/page_4.html Executable file
View File

@ -0,0 +1,12 @@
<html>
<head>
<title>Title</title>
<link rel="stylesheet" type="text/css" href="stil.css"></link>
<style>
</style>
</head>
<body>
</body>
</html>

View File

@ -0,0 +1,12 @@
import org.junit.Test;
import static org.junit.Assert.*;
public class JUnitDemoTest {
@Test
public void getName() {
JUnitDemo demo = new JUnitDemo("İhsan");
assertEquals("İhsan", demo.getName());
}
}

View File

@ -0,0 +1,41 @@
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class MainTest {
String testPesel;
@Before
public void setUp() throws Exception {
testPesel = "98032614335";
}
@Test/*(expected = NumberFormatException.class)*/
public void checkPesel() {
long pesel = Long.valueOf(testPesel);
assertTrue(testPesel.length() == 11);
int checkSum = 0;
int lastDigit = (int)( pesel % 10);
pesel /= 10;
checkSum += 3 * (pesel % 10);
pesel /= 10;
checkSum += 1 * (pesel % 10);
pesel /= 10;
checkSum += 9 * (pesel % 10);
pesel /= 10;
checkSum += 7 * (pesel % 10);
pesel /= 10;
checkSum += 3 * (pesel % 10);
pesel /= 10;
checkSum += 1 * (pesel % 10);
pesel /= 10;
checkSum += 9 * (pesel % 10);
pesel /= 10;
checkSum += 7 * (pesel % 10);
pesel /= 10;
checkSum += 3 * (pesel % 10);
pesel /= 10;
checkSum += 1 * (pesel % 10);
assertTrue((10 - (checkSum % 10)) % 10 == lastDigit );
}
}

5
src/test/java/Test.java Normal file
View File

@ -0,0 +1,5 @@
public class Test {
public static void main(String[] args) {
System.out.println("Testing Run");
}
}

Binary file not shown.

Binary file not shown.

BIN
target/classes/Main.class Normal file

Binary file not shown.

13
target/classes/d.txt Normal file
View File

@ -0,0 +1,13 @@
mvn install:install-file \
-Dfile=${basedir}/lib/jsoup-1.12.1.jar \
-DgroupId=Parser \
-DartifactId=jsoup \
-Dversion=1.12.1 \
-Dpackaging=jar \
-DgeneratePom=true
mvn deploy:deploy-file -DgroupId=[GROUP] -DartifactId=[ARTIFACT] -Dversion=[VERS] -Durl=file:./lib/local-maven-repo/ -DrepositoryId=local-maven-repo -DupdateReleaseInfo=true -Dfile=[FILE_PATH]
mvn install:install-file -Dfile=./lib/jsoup-1.12.1.jar -DgroupId=Parser -DartifactId=jsoup -Dversion=1.12.1 -DlocalRepositoryPath=./lib/ -Dpackaging=jar

12
target/classes/iskelet.html Executable file
View File

@ -0,0 +1,12 @@
<html>
<head>
<title>Title</title>
<link rel="stylesheet" type="text/css" href="stil.css"></link>
<style>
</style>
</head>
<body>
</body>
</html>

18
target/classes/page_1.html Executable file
View File

@ -0,0 +1,18 @@
<html>
<head>
<title>First Page</title>
<link rel="stylesheet" type="text/css" href="stil.css"></link>
<style>
</style>
</head>
<body>
<a href="home">HomePage</a>
<a href="https://www.google.com">Google</a>
<a href="https://www.github.com">Github</a>
<a href="aboutus">About Us</a>
<a href="courses">Courses</a>
<a href="https://www.tureng.com">Tureng</a>
<a>link element without a href attribute this won't show up in program.</a>
</body>
</html>

12
target/classes/page_2.html Executable file
View File

@ -0,0 +1,12 @@
<html>
<head>
<title>Title</title>
<link rel="stylesheet" type="text/css" href="stil.css"></link>
<style>
</style>
</head>
<body>
</body>
</html>

12
target/classes/page_3.html Executable file
View File

@ -0,0 +1,12 @@
<html>
<head>
<title>Title</title>
<link rel="stylesheet" type="text/css" href="stil.css"></link>
<style>
</style>
</head>
<body>
</body>
</html>

12
target/classes/page_4.html Executable file
View File

@ -0,0 +1,12 @@
<html>
<head>
<title>Title</title>
<link rel="stylesheet" type="text/css" href="stil.css"></link>
<style>
</style>
</head>
<body>
</body>
</html>

View File

@ -0,0 +1,3 @@
/home/ihsan/Documents/proLab/Project_1/src/main/java/HTMLParser.java
/home/ihsan/Documents/proLab/Project_1/src/main/java/Main.java
/home/ihsan/Documents/proLab/Project_1/src/main/java/JUnitDemo.java

Binary file not shown.

Binary file not shown.

Binary file not shown.