Skip to content

Commit

Permalink
more on add legends and images
Browse files Browse the repository at this point in the history
  • Loading branch information
homberghp committed Feb 21, 2024
1 parent 1ccfb0b commit 68b4b56
Show file tree
Hide file tree
Showing 9 changed files with 781 additions and 90 deletions.
447 changes: 447 additions & 0 deletions static/images/exceptionhierarchy.uxf

Large diffs are not rendered by default.

Binary file added static/images/logging-activation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
169 changes: 91 additions & 78 deletions static/images/throwandcatch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
217 changes: 217 additions & 0 deletions static/images/throwandcatch.uxf
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<diagram program="umlet" version="15.1">
<zoom_level>10</zoom_level>
<element>
<id>UMLClass</id>
<coordinates>
<x>310</x>
<y>100</y>
<w>440</w>
<h>130</h>
</coordinates>
<panel_attributes>halign=left
public void method2() throws Exception {

if (some error occors) {

throw new Exception( "with some message and other info");
}
}


</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>30</x>
<y>80</y>
<w>250</w>
<h>250</h>
</coordinates>
<panel_attributes>halign=left
public void method1(){
try {
method2();

* } catch( Exception ex ){*

// Process exception ex;

* } finally {*

// do some cleanup
// will allways be executed
}

}

</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>470</x>
<y>100</y>
<w>130</w>
<h>30</h>
</coordinates>
<panel_attributes>halign=left
lt=.
bg=green


</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>320</x>
<y>170</y>
<w>160</w>
<h>20</h>
</coordinates>
<panel_attributes>halign=left
lt=.
bg=pink


</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLNote</id>
<coordinates>
<x>230</x>
<y>40</y>
<w>140</w>
<h>30</h>
</coordinates>
<panel_attributes>bg=yellow
catch exception</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>210</x>
<y>60</y>
<w>70</w>
<h>100</h>
</coordinates>
<panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>10.0;80.0;50.0;10.0</additional_attributes>
</element>
<element>
<id>UMLNote</id>
<coordinates>
<x>440</x>
<y>250</y>
<w>140</w>
<h>40</h>
</coordinates>
<panel_attributes>halign=left
lt=.
bg=pink
throw exception</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLNote</id>
<coordinates>
<x>560</x>
<y>50</y>
<w>150</w>
<h>30</h>
</coordinates>
<panel_attributes>halign=left
lt=.
bg=green
declare exception</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>520</x>
<y>50</y>
<w>60</w>
<h>70</h>
</coordinates>
<panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>10.0;50.0;40.0;10.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>410</x>
<y>180</y>
<w>50</w>
<h>100</h>
</coordinates>
<panel_attributes>lt=&lt;-
bg=yellow</panel_attributes>
<additional_attributes>10.0;10.0;30.0;80.0</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>40</x>
<y>140</y>
<w>200</w>
<h>70</h>
</coordinates>
<panel_attributes>halign=left
lt=.
bg=yellow


</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>40</x>
<y>210</y>
<w>200</w>
<h>90</h>
</coordinates>
<panel_attributes>halign=left
lt=.
bg=cyan


</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLNote</id>
<coordinates>
<x>300</x>
<y>300</y>
<w>170</w>
<h>30</h>
</coordinates>
<panel_attributes>halign=left
lt=.
bg=cyan
optional finally block</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>230</x>
<y>260</y>
<w>90</w>
<h>70</h>
</coordinates>
<panel_attributes>lt=&lt;-
bg=yellow</panel_attributes>
<additional_attributes>10.0;10.0;70.0;50.0</additional_attributes>
</element>
</diagram>
12 changes: 6 additions & 6 deletions topics/code/exex/src/exex/CircleWithRadiusException.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class CircleWithRadiusException {

/**
* The radius of the circle
* The radius of the circle.
*/
private double radius;

Expand All @@ -13,14 +13,14 @@ public class CircleWithRadiusException {
private static int numberOfObjects = 0;

/**
* Construct a circle with radius 1
* Construct a circle with radius 1.
*/
public CircleWithRadiusException() {
this(1.0);
}

/**
* Construct a circle with a specified radius
* Construct a circle with a specified radius.
*/
public CircleWithRadiusException(double newRadius) {
try {
Expand All @@ -32,7 +32,7 @@ public CircleWithRadiusException(double newRadius) {
}

/**
* Return radius
* Return radius.
*/
public double getRadius() {
return radius;
Expand All @@ -51,14 +51,14 @@ public void setRadius(double newRadius)
}

/**
* Return numberOfObjects
* Return numberOfObjects.
*/
public static int getNumberOfObjects() {
return numberOfObjects;
}

/**
* Return the area of this circle
* Return the area of this circle.
*/
public double findArea() {
return radius * radius * 3.14159;
Expand Down
4 changes: 2 additions & 2 deletions topics/collectionenhancements.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ and of course
map.forEach((k, v) -> System.out.println(k + "=" + v));
----

The fun thing is that all these methods are default methods, so they apply to all classes that implement the java.util.Map interface, including the ones you roll yourselves,
might you feel the inclination. To implement a special map that has specific extra properties, you only need to extend https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/AbstractMap.html[AbstractMap]
The fun thing is that all these methods are default methods, so they apply to all classes that implement the java.util.Map interface, including the ones you roll yourselves, might you feel the inclination. To implement a special map that has specific extra properties,
you only need to extend https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/AbstractMap.html[AbstractMap]
which needs the implementation of one or two methods only, depending if you want an unmodifiable of modifiable one.
8 changes: 7 additions & 1 deletion topics/internationalisation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public void tLength( String line, String p1, String p2, double expected,
* @return the double
* @throws ParseException if the string does not parse to double.
*/
static double getDoubleConsideringLocale( String input ) throws ParseException {
static double getDoubleConsideringLocale( String input )
throws ParseException {
return DecimalFormat.getNumberInstance().parse( input ).doubleValue(); // <1>
}
Expand All @@ -90,8 +91,13 @@ static double getDoubleConsideringLocale( String input ) throws ParseException {
* @return the double.
* @throws ParseException if the string does not parse to double.
*/
<<<<<<< Updated upstream
static double getDoubleConsideringLocale( Locale locale, String input )
throws ParseException {
=======
static double getDoubleConsideringLocale( Locale locale, String input )
throws ParseException {
>>>>>>> Stashed changes
return DecimalFormat.getNumberInstance(locale).parse( input ).doubleValue();
}
----
Expand Down
9 changes: 7 additions & 2 deletions topics/logging.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ public static void main( String[] args ) {

<1> Create a specific logger for this class.
<2> This log statement only does 'work' when the log level is set to FINE or higher (FINER, FINEST)
<<<<<<< Updated upstream
<3> Note the use of positional parameters in the format string. It can be quite useful. See it as a free and random tip.
<4> This lambda has the shape of a supplier and is only evaluated or computed when the logging level is active.
=======
<3> This lambda has the shape of a supplier and is only evaluated or computed when the logging level is active. This
make logging 'cheap' when the log level is not active.
>>>>>>> Stashed changes

=== Replace `soutv`` by using a log macro

Expand Down Expand Up @@ -58,7 +63,7 @@ logdem.LogDem.level=FINE #<2>
<2> specify for one class
Then in the java startup (for instance in a run script or in one of the IDE settings), make sure this java property specifies the file.

For NetBeans add [blue]`-Djava.util.logging.config.file=conf/logging.properties` to the java run actions.
In your IDE add [blue]`-Djava.util.logging.config.file=conf/logging.properties` to the java run actions.

Say the class that needs debugging is called `logging.Main`. Then in the logging properties file (see above) add
`logging.Main.level = FINE`, and make sure that you start the JVM with the proper login properties file.
Expand All @@ -69,7 +74,7 @@ You can also set the parameter in the 'run-configuration' of your project.
Add the appropriate option there, e.g. -Djava.util.logging.config.file=conf/logging.properties
.point to project specific log file.
image::run-logging.png[]
image::logging-activation.png[title="Project specific logging in NetBeans IDE"]
====

Expand Down
5 changes: 4 additions & 1 deletion topics/security.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ that has one column named `secret` we could retrieve the secrets as follows:
<3> Get all the columns for table `secrets` -> returns `secret`
<4> Get the secret

The strange coloring in the box above is due to the fact that we confuse the ascidoctor syntax highlighting.


==== Database management

The reason that the in the previous section we were able to retrieve
Expand Down Expand Up @@ -550,7 +553,7 @@ to a group and inherit all the rights of that group.
This is of course only a step in the right direction, there are more steps
that can be taken to harden your database (depending on your needs):

* Disable login (only local over unix socket)
* Disable login (only local over unix socket, possible on Windows also since the support of unix sockets there too. (Java 16))
* Only login in from localhost or specific IP
* Login using certificates instead of password
* Enable logging
Expand Down

0 comments on commit 68b4b56

Please sign in to comment.