Skip to content

Commit

Permalink
finished ex3 with docs
Browse files Browse the repository at this point in the history
  • Loading branch information
abdo643-HULK committed Jan 20, 2022
1 parent acc59e3 commit c9d5fb4
Show file tree
Hide file tree
Showing 35 changed files with 571 additions and 203 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 3 additions & 16 deletions EX2/.idea/modules/rmi/client/EX2.rmi.client.main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 3 additions & 16 deletions EX2/.idea/modules/rmi/server/EX2.rmi.server.main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 3 additions & 23 deletions EX2/.idea/modules/servlets/EX2.servlets.main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 3 additions & 22 deletions EX2/.idea/modules/servlets/EX2.servlets.test.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions EX3/.gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
cmake-build-debug
out
.idea/
gradle.properties

.gradle
# Ignore Gradle build output directory
build

.idea/$CACHE_FILE$

### https://raw.github.com/github/gitignore/44cbb3686c18f634a488ea123d1148ca9a64fa22/Global/JetBrains.gitignore

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

.idea/
.idea/$CACHE_FILE$
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
Expand Down Expand Up @@ -68,4 +68,6 @@ atlassian-ide-plugin.xml
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
fabric.properties

!.idea/artifacts/hello.xml
5 changes: 4 additions & 1 deletion EX3/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import org.jetbrains.gradle.ext.ProjectSettings
import org.jetbrains.gradle.ext.BuildArtifact

plugins {
java
idea
checkstyle
kotlin("jvm") version "1.6.10"
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.1"
}

version = "1.0.0"
Expand Down
2 changes: 0 additions & 2 deletions EX3/jaxb/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ plugins {
kotlin("jvm")
}

version = "1.0.0"

repositories {
mavenCentral()
}
Expand Down
26 changes: 21 additions & 5 deletions EX3/jaxb/src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Marshaller;
import org.eclipse.persistence.jaxb.MarshallerProperties;
import org.eclipse.persistence.jaxb.UnmarshallerProperties;
import org.eclipse.persistence.oxm.MediaType;
import org.eclipse.persistence.jaxb.UnmarshallerProperties;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.transform.stream.StreamSource;
import java.io.StringReader;
import java.io.StringWriter;


/**
* Our class that Tests the Jaxb
* marshaller and unmarshaller
*/
public class Main {
/**
* The first part parses the xml string and
* constructs a Pet Object and this
* again gets serialized to a xml string
*
* The second part parses the json string and
* constructs a Pet Object and this
* again gets serialized to a json string
*
* @param _args the args passed to the program
*/
public static void main(String[] _args) {
System.setProperty("jakarta.xml.bind.JAXBContextFactory", "org.eclipse.persistence.jaxb.JAXBContextFactory");
// System.setProperty("jakarta.xml.bind.JAXBContextFactory", "org.eclipse.persistence.jaxb.JAXBContextFactory");
System.setProperty("javax.xml.bind.JAXBContextFactory","org.eclipse.persistence.jaxb.JAXBContextFactory");

try {
System.out.println("-------------- XML --------------");
var xmlString = new StringReader("""
Expand Down
29 changes: 27 additions & 2 deletions EX3/jaxb/src/main/java/Pet.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import jakarta.xml.bind.annotation.*;

import javax.xml.bind.annotation.*;
import java.util.Arrays;
import java.util.Date;

/**
* the Pet class for our jaxb Exercise
*/
@XmlRootElement(name = "pet")
@XmlType(propOrder = { "mName", "mTyp", "mId", "mBirthday", "mVaccinations" })
@XmlType(propOrder = {"mName", "mTyp", "mId", "mBirthday", "mVaccinations"})
public class Pet {
@XmlElement(name = "name")
String mName;
Expand Down Expand Up @@ -46,4 +49,26 @@ public String toString() {
+ "\nVaccinations: " + Arrays.toString(mVaccinations)
+ "\nID: " + mId;
}

public String getmName() {
return mName;
}

public Type getmTyp() {
return mTyp;
}

public String getmId() {
return mId;
}

public Date getmBirthday() {
return mBirthday;
}

public String[] getmVaccinations() {
return mVaccinations;
}


}
3 changes: 3 additions & 0 deletions EX3/jaxb/src/main/java/Type.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* For the supported Pet types
*/
public enum Type {
CAT,
DOG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,28 @@
import java.util.regex.*;
import java.util.*;

class WGS {
/**
* Class that holds the values of the example to parse
*/
class Wgs {
final float mLatitude;
final float mLongitude;

WGS(float _latitude, float _longitude) {
Wgs(float _latitude, float _longitude) {
mLatitude = _latitude;
mLongitude = _longitude;
}

/**
* Parses the xml string with the
* help of a regex and puts
* the result into a hashmap
* from the result we construct
* the object with the properties
* from the map
*
* @param _args the args passed to the program
*/
public static void main(String[] _args) {
var xml = "<wgs84><latitude>48.31</latitude><longitude>14.29</longitude></wgs84>";

Expand All @@ -32,7 +45,7 @@ public static void main(String[] _args) {
}
}

var wgs84 = new WGS(map.get("latitude"), map.get("longitude"));
var wgs84 = new Wgs(map.get("latitude"), map.get("longitude"));

System.out.println(wgs84);
}
Expand Down
Loading

0 comments on commit c9d5fb4

Please sign in to comment.