16 |
17 |
18 |
--------------------------------------------------------------------------------
/installers/uninstall.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | setlocal enableextensions
3 |
4 | set folder=%ProgramFiles%\svetovid-lib
5 | set variable=CLASSPATH
6 |
7 | rem Check if administrator
8 | net session >nul 2>&1
9 | if errorLevel 1 (
10 | echo Please run as administrator
11 | exit /b
12 | )
13 |
14 | rem Remove the folder
15 | rmdir /s /q "%folder%" >nul 2>&1
16 |
17 | rem UnsSet the class path
18 | REG delete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /F /V "%variable%" >nul 2>&1
19 |
20 |
--------------------------------------------------------------------------------
/doc/sr/primeri/DopisivanjeUFajl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Ovaj primer prikazuje dopisivanje na kraj postojeceg fajla, koriscenje
3 | * opcije "append" umesto "out". Svaki put kad se program pokrene dopisace na
4 | * kraj fajla "novi.txt" po dva reda. Ako fajl nije postojao bice napravljen.
5 | */
6 | public class DopisivanjeUFajl {
7 |
8 | public static void main(String[] args) {
9 | Svetovid.append("novi.txt").println("Dodatni red");
10 | Svetovid.append("novi.txt").println("Drugi dodatni red");
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/doc/README.txt:
--------------------------------------------------------------------------------
1 | For documentation in English please refer to the "en" subfolder.
2 | The files have "markdown" extensions for additional formating, but
3 | are basically just regular text files and can be opened and edited
4 | with any text editor.
5 |
6 | Dokumentacija na srpskom jeziku je u podfolderu "sr".
7 | Fajlovi imaju ekstenzije "markdown" jer imaju specijalne oznake
8 | koje se odnose na formatiranje, medjutim u pitanju su obicni tekstualni
9 | fajlovi koji se mogu otvoriti u bilo kojem editoru i citati takvi
10 | kakvi su.
11 |
--------------------------------------------------------------------------------
/doc/PROCITAJME.txt:
--------------------------------------------------------------------------------
1 | Dokumentacija na srpskom jeziku je u podfolderu "sr".
2 | Fajlovi imaju ekstenzije "markdown" jer imaju specijalne oznake
3 | koje se odnose na formatiranje, medjutim u pitanju su obicni tekstualni
4 | fajlovi koji se mogu otvoriti u bilo kojem editoru i citati takvi
5 | kakvi su.
6 |
7 | For documentation in English please refer to the "en" subfolder.
8 | The files have "markdown" extensions for additional formating, but
9 | are basically just regular text files and can be opened and edited
10 | with any text editor.
11 |
--------------------------------------------------------------------------------
/doc/sr/primeri/PisanjeUFajl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Ovaj primer demonstrira pisanje u novi fajl. Ako fajl ne postoji bice
3 | * napravljen, a ako fajl postoji bice zamenjen sa ovim sadrzajem. Na kraju
4 | * rada programa ce u fajlu sa imenom "novi.txt" biti upisana dva reda.
5 | */
6 | public class PisanjeUFajl {
7 |
8 | public static void main(String[] args) {
9 | Svetovid.out.println("Pisanje dva reda u fajl");
10 | Svetovid.out("novi.txt").println("prvi red");
11 | Svetovid.out("novi.txt").println("drugi red");
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | Copyright 2015 Ivan Pribela
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/res/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: Supplement Library for Introductory Programming Courses
4 | Bundle-SymbolicName: org.svetovid.lib
5 | Bundle-Version: 0.5.1
6 | Bundle-Vendor: Ivan Pribela
7 | Bundle-RequiredExecutionEnvironment: JavaSE-1.7
8 | Export-Package: .;version="0.5.1",
9 | org.svetovid;version="0.5.1";uses:="org.svetovid.io,org.svetovid.dialogs",
10 | org.svetovid.dialogs;version="0.5.1";uses:="javax.swing",
11 | org.svetovid.io;version="0.5.1",
12 | org.svetovid.run;version="0.5.1",
13 | org.svetovid.util;version="0.5.1"
14 | Main-Class: Svetovid
15 |
--------------------------------------------------------------------------------
/doc/README.md:
--------------------------------------------------------------------------------
1 | # Svetovid-lib Documentation
2 |
3 | For documentation in English please refer to the
4 | ["en" subfolder](en/README.markdown).
5 |
6 | The files have "markdown" extensions for additional formating, but
7 | are basically just regular text files and can be opened and edited
8 | with any text editor.
9 |
10 | # Svetovid-lib dokumentacija
11 |
12 | Dokumentacija na srpskom jeziku je u [podfolderu "sr"](sr/README.markdown).
13 |
14 | Fajlovi imaju ekstenzije "markdown" jer imaju specijalne oznake
15 | koje se odnose na formatiranje, medjutim u pitanju su obicni tekstualni
16 | fajlovi koji se mogu otvoriti u bilo kojem editoru i citati takvi
17 | kakvi su.
18 |
--------------------------------------------------------------------------------
/installers/install-svetovid-lib.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | setlocal enableextensions
3 |
4 | set url=https://svetovid.org/lib/svetovid-lib.jar
5 | set folder=%ProgramFiles%\svetovid-lib
6 | set file=svetovid-lib.jar
7 | set variable=CLASSPATH
8 |
9 | rem Check if administrator
10 | net session >nul 2>&1
11 | if errorLevel 1 (
12 | echo Please run as administrator
13 | exit /b
14 | )
15 |
16 | if not exist %file% (
17 | echo Please download %file% to this folder from %url%
18 | exit /b
19 | )
20 |
21 | rem Create the folder
22 | mkdir "%folder%" >nul 2>&1
23 |
24 | rem Copy the library
25 | copy "%~dp0%file%" "%folder%\%file%" >nul 2>&1
26 |
27 | rem Set the class path
28 | setx "%variable%" "%folder%\%file%;." /m >nul 2>&1
29 |
30 |
--------------------------------------------------------------------------------
/src/start.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | public class start {
18 | public static void main(String[] arguments) {
19 | org.svetovid.run.Start.main(arguments);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ressrc/i18n/dialog_sr.properties:
--------------------------------------------------------------------------------
1 | # Titles
2 | message = Порука
3 | information = Информација
4 | warning = Упозорење
5 | error = Грешка
6 | confirmation = Потврда
7 | question = Питање
8 | password = Лозинка
9 | login = Пријава
10 | exception = Изузетак
11 |
12 | # Options
13 | ok = Уреду
14 | cancel = Откажи
15 | yes = Да
16 | no = Не
17 | loginok = Уреду
18 | logincancel = Излаз
19 | details = Детаљи
20 |
21 | #Labels
22 | loginUsername = Корисничко име:
23 | loginPassword = Лозинка:
24 | stackTraceNative = Системски метод
25 | stackTraceUnknown = Непознат извор
26 | stackTraceCause = Узрок:
27 | stackTraceMore = ... још {0}
28 | timeout = {0} s
29 | timeoutTip = Овај дијалог ће се сам затворити после одређеног времена. Кликните овде или притисните било који тастер да зауставите одбројавање.
30 |
31 | # Icons
32 |
--------------------------------------------------------------------------------
/ressrc/i18n/dialog_sr_LATIN.properties:
--------------------------------------------------------------------------------
1 | # Titles
2 | message = Poruka
3 | information = Informacija
4 | warning = Upozorenje
5 | error = Greška
6 | confirmation = Potvrda
7 | question = Pitanje
8 | password = Lozinka
9 | login = Prijava
10 | exception = Izuzetak
11 |
12 | # Options
13 | ok = Uredu
14 | cancel = Otkaži
15 | yes = Da
16 | no = Ne
17 | loginok = Uredu
18 | logincancel = Izlaz
19 | details = Detalji
20 |
21 | #Labels
22 | loginUsername = Korisničko ime:
23 | loginPassword = Lozinka:
24 | stackTraceNative = Sistemski metod
25 | stackTraceUnknown = Nepoznat izvor
26 | stackTraceCause = Uzrok:
27 | stackTraceMore = ... još {0}
28 | timeout = {0} s
29 | timeoutTip = Ovaj diajalog će se sam zatvoriti posle određenog vremena. Kliknite ovde ili pritisnite bilo koji taster da zaustavite odbrojavanje.
30 |
31 | # Icons
32 |
--------------------------------------------------------------------------------
/src/org/svetovid/installer/Collector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.installer;
18 |
19 | public interface Collector {
20 |
21 | public void collect(T item);
22 | }
23 |
--------------------------------------------------------------------------------
/res/i18n/dialog_sr_LATIN.properties:
--------------------------------------------------------------------------------
1 | # Titles
2 | message = Poruka
3 | information = Informacija
4 | warning = Upozorenje
5 | error = Gre\u0161ka
6 | confirmation = Potvrda
7 | question = Pitanje
8 | password = Lozinka
9 | login = Prijava
10 | exception = Izuzetak
11 |
12 | # Options
13 | ok = Uredu
14 | cancel = Otka\u017ei
15 | yes = Da
16 | no = Ne
17 | loginok = Uredu
18 | logincancel = Izlaz
19 | details = Detalji
20 |
21 | #Labels
22 | loginUsername = Korisni\u010dko ime:
23 | loginPassword = Lozinka:
24 | stackTraceNative = Sistemski metod
25 | stackTraceUnknown = Nepoznat izvor
26 | stackTraceCause = Uzrok:
27 | stackTraceMore = ... jo\u0161 {0}
28 | timeout = {0} s
29 | timeoutTip = Ovaj diajalog \u0107e se sam zatvoriti posle odre\u0111enog vremena. Kliknite ovde ili pritisnite bilo koji taster da zaustavite odbrojavanje.
30 |
31 | # Icons
32 |
--------------------------------------------------------------------------------
/ressrc/i18n/dialog_de.properties:
--------------------------------------------------------------------------------
1 | # Titles
2 | message = Mitteilung
3 | information = Information
4 | warning = Achtung
5 | error = Fehler
6 | confirmation = Bestätigung
7 | question = Frage
8 | password = Passwort
9 | login = Anmelden
10 | exception = Ausnahmefall
11 |
12 | # Options
13 | ok = OK
14 | cancel = Abbrechen
15 | yes = Ja
16 | no = Nein
17 | loginok = Anmelden
18 | logincancel = Abbrechen
19 | details = Detailansicht
20 |
21 | #Labels
22 | loginUsername = Benutzername:
23 | loginPassword = Passwort:
24 | stackTraceNative = native Methode
25 | stackTraceUnknown = unbekannte Quelle
26 | stackTraceCause = Verursacht durch:
27 | stackTraceMore = ... {0} mehr
28 | timeout = {0} s
29 | timeoutTip = Dieser Dialog wird sich nach einer bestimmten Zeit schließen. Bitte klicken oder eine Taste drücken, um den Countdown zu stoppen.
30 |
31 | # Icons
32 |
--------------------------------------------------------------------------------
/res/i18n/dialog_de.properties:
--------------------------------------------------------------------------------
1 | # Titles
2 | message = Mitteilung
3 | information = Information
4 | warning = Achtung
5 | error = Fehler
6 | confirmation = Best\u00e4tigung
7 | question = Frage
8 | password = Passwort
9 | login = Anmelden
10 | exception = Ausnahmefall
11 |
12 | # Options
13 | ok = OK
14 | cancel = Abbrechen
15 | yes = Ja
16 | no = Nein
17 | loginok = Anmelden
18 | logincancel = Abbrechen
19 | details = Detailansicht
20 |
21 | #Labels
22 | loginUsername = Benutzername:
23 | loginPassword = Passwort:
24 | stackTraceNative = native Methode
25 | stackTraceUnknown = unbekannte Quelle
26 | stackTraceCause = Verursacht durch:
27 | stackTraceMore = ... {0} mehr
28 | timeout = {0} s
29 | timeoutTip = Dieser Dialog wird sich nach einer bestimmten Zeit schlie\u00dfen. Bitte klicken oder eine Taste dr\u00fccken, um den Countdown zu stoppen.
30 |
31 | # Icons
32 |
--------------------------------------------------------------------------------
/src/org/svetovid/util/OperatingSystemFamily.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.util;
18 |
19 | public enum OperatingSystemFamily {
20 |
21 | WINDOWS,
22 | MAC,
23 | UNIX,
24 | OTHER;
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/fragments/html/style.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: "Droid sans", Sans-serif;
3 | background-color: #abc;
4 | color: black;
5 | }
6 |
7 | a,
8 | a:active,
9 | a:visited {
10 | color: #006;
11 | text-decoration: underline;
12 | border: none;
13 | }
14 |
15 | a:hover {
16 | color: #33a;
17 | text-decoration: none;
18 | }
19 |
20 | #main {
21 | margin: auto;
22 | max-width: 800px;
23 | background: #eee;
24 | padding: 2ex;
25 | border-radius: 15px;
26 | }
27 |
28 | #TOC {
29 | float: right;
30 | border-radius: 15px;
31 | border: solid #ccc;
32 | padding: 0.5ex;
33 | }
34 |
35 | .nav {
36 | border: solid 1pt black;
37 | border-left: none;
38 | border-right: none;
39 | padding: 1ex;
40 | background: #ddd;
41 | }
42 |
43 | h1 {
44 | border-bottom: solid 1pt;
45 | text-shadow: #bbb 0.1em 0.1em;
46 | clear: both;
47 | }
48 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.svetovid.lib
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.pde.ManifestBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.pde.SchemaBuilder
20 |
21 |
22 |
23 |
24 |
25 | org.eclipse.pde.PluginNature
26 | org.eclipse.jdt.core.javanature
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/org/svetovid/demo/HelloWorld.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.demo;
18 |
19 | import org.svetovid.Svetovid;
20 |
21 | public class HelloWorld {
22 |
23 | public static void main(String[] args) {
24 |
25 | // Ask for a name
26 | String name = Svetovid.in.readLine("Please enter your name:");
27 |
28 | // Greet the user
29 | Svetovid.out.println("Hello " + name + "!");
30 |
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/doc/sr/README.markdown:
--------------------------------------------------------------------------------
1 | Dokumentacija biblioteke Svetovid-lib
2 | =====================================
3 |
4 | Svetovid-lib je biblioteka namenjena pojednostavljivanju mnogih osnovnih radnji
5 | u programskom jeziku Java kao što je rad sa standardnim ulazom i izlazom, te rad
6 | sa fajlovima. Prvenstveno je namenjena programerima početnicima koje nije
7 | neophodno dodatno opterećivati relativno kompleksnim pojmovima potrebnim za ove
8 | osnovne operacije u okviru jezika. Naravno, biblioteka se takođe može koristiti
9 | i za bilo kakve druge naprednije svrhe. Naročito od koristi mogu biti, pored
10 | ulazno-izlaznih operacija, brojni pomoćni metodi za rad sa kompleksnijim
11 | tipovima, kao i rad sa dijalozima.
12 |
13 | Dokumentacija je podeljena na više malih fajlova koji se bave određenim temama.
14 |
15 | [O instalaciji biblioteke i testiranju instalacije](instalacija.markdown)
16 |
17 | [Učitavanje i ispisivanje](ucitavanje-i-ispisivanje.markdown)
18 |
19 | [Rad sa fajlovima](rad-sa-fajlovima.markdown)
20 |
21 | Primeri programa
22 | ----------------
23 |
24 | Primeri programa se mogu naći u podfolderu [primeri](primeri).
25 |
--------------------------------------------------------------------------------
/src/org/svetovid/installer/JavaInstallationVersionType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.installer;
18 |
19 | public enum JavaInstallationVersionType {
20 |
21 | /**
22 | * Version is not known.
23 | */
24 | NONE,
25 |
26 | /**
27 | * Version is older.
28 | */
29 | OLDER,
30 |
31 | /**
32 | * Version is the same.
33 | */
34 | EQUAL,
35 |
36 | /**
37 | * Version is newer.
38 | */
39 | NEWER;
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/org/svetovid/dialogs/DialogContent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.dialogs;
18 |
19 | /**
20 | * This is an interface for objects that can be used as content in dialogs. This
21 | * interface provides a method for retrieving the content component and a method
22 | * for retrieving user selected value to return when the dialog is closed.
23 | *
24 | * @author Ivan Pribela
25 | * @version 1.0
26 | */
27 | public interface DialogContent {
28 |
29 | public Object getContent();
30 |
31 | public T getValue();
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/org/svetovid/installer/JavaInstallationType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.installer;
18 |
19 | public enum JavaInstallationType {
20 |
21 | /**
22 | * Java Development Kit installation.
23 | */
24 | JDK,
25 |
26 | /**
27 | * Java Runtime Environment installation.
28 | */
29 | JRE,
30 |
31 | /**
32 | * Unknown Java installation.
33 | */
34 | UNKNOWN,
35 |
36 | /**
37 | * Synthetic, represents all Java Installations on the machine
38 | */
39 | ALL;
40 | }
41 |
--------------------------------------------------------------------------------
/src/org/svetovid/installer/JavaInstallationSetCollector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.installer;
18 |
19 | import java.util.Set;
20 | import java.util.TreeSet;
21 |
22 | public class JavaInstallationSetCollector implements Collector {
23 |
24 | private Set set = new TreeSet<>();
25 |
26 | @Override
27 | public void collect(JavaInstallation installation) {
28 | set.add(installation);
29 | }
30 |
31 | public Set getCollected() {
32 | return set;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/installers/uninstall.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | folder='/usr/local/lib'
4 | file='svetovid-lib.jar'
5 | config='/etc/environment'
6 | variable='CLASSPATH'
7 |
8 | # Check if administrator
9 | if [ $(id -u) -ne 0 ]; then
10 | echo "Please run as administrator"
11 | exit
12 | fi
13 |
14 | # Check if sed is available
15 | sed --version >/dev/null 2>&1
16 | if [ $? -ne 0 ]; then
17 | echo "Sed is not available, please remove the CLASSPATH entries manually from $config"
18 | exit
19 | fi
20 |
21 | # Remove the file
22 | rm -rf "$folder/$file"
23 |
24 | if [ $? -e 0 ]; then
25 | echo "File $file removed from system"
26 | else
27 | echo "Problem with removing the file $folder/$file"
28 | fi
29 |
30 | echo "This will now remove the CLASSPATH entry from $config entirely."
31 | echo "If you have additional modifications to this entry, they will be removed."
32 | echo "If you want to keep those, stop this process and change CLASSPATH manually."
33 | read -p "Continue? [Yn]" input
34 |
35 | if [ -n $input ] && [ $input != "Y" ]; then
36 | exit
37 | fi
38 |
39 | # Unset the class path
40 | if grep -q "$variable" "$config" 2>/dev/null; then
41 | sed -i "/$variable=.*/d" "$config"
42 | fi
43 |
44 | echo "CLASSPATH entry removed from $config"
45 |
--------------------------------------------------------------------------------
/src/org/svetovid/demo/GasNeeded.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.demo;
18 |
19 | import org.svetovid.Svetovid;
20 |
21 | public class GasNeeded {
22 |
23 | public static void main(String[] args) {
24 |
25 | // Ask for data
26 | double distance = Svetovid.in.readDouble("What is the distance in kilometers?");
27 | double usage = Svetovid.in.readDouble("How many kilometres can your car travel per liter of gas?");
28 |
29 | // Calculate the gas needed
30 | double needed = distance / usage;
31 | Svetovid.out.println("You will need", needed, "liters of gas for your journey.");
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/org/svetovid/io/StandardSvetovidWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.io;
18 |
19 | /**
20 | * This class provides an implementation of the {@link SvetovidWriter} interface
21 | * that writes all the output to the "standard" output (see {@link System#out}).
22 | *
23 | * @author Ivan Pribela
24 | *
25 | * @see System#out
26 | * @see SvetovidWriter
27 | */
28 | public class StandardSvetovidWriter extends DefaultSvetovidWriter {
29 |
30 | /**
31 | * Creates a new writer that writes all the output to the "standard" output.
32 | */
33 | public StandardSvetovidWriter() {
34 | super(new StandardOutputStreamProxy());
35 | autoFlush = true;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/org/svetovid/io/StandardSvetovidErrorWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.io;
18 |
19 | /**
20 | * This class provides an implementation of the {@link SvetovidWriter} interface
21 | * that writes all the output to the "standard" error output (see
22 | * {@link System#err} ).
23 | *
24 | * @author Ivan Pribela
25 | *
26 | * @see System#err
27 | * @see SvetovidWriter
28 | */
29 | public class StandardSvetovidErrorWriter extends DefaultSvetovidWriter {
30 |
31 | /**
32 | * Creates a new writer that writes all the output to the "standard" error
33 | * output.
34 | */
35 | public StandardSvetovidErrorWriter() {
36 | super(new StandardErrorStreamProxy());
37 | autoFlush = true;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/res/i18n/dialog.properties:
--------------------------------------------------------------------------------
1 | # Titles
2 | message = Message
3 | information = Information
4 | warning = Warning
5 | error = Error
6 | confirmation = Confirmation
7 | question = Question
8 | password = Password
9 | login = Login
10 | exception = Exception
11 |
12 | # Options
13 | ok = Ok
14 | cancel = Cancel
15 | yes = Yes
16 | no = No
17 | loginok = Login
18 | logincancel = Exit
19 | details = Details
20 |
21 | #Labels
22 | loginUsername = Username:
23 | loginPassword = Password:
24 | stackTraceNative = Native Method
25 | stackTraceUnknown = Unknown Source
26 | stackTraceCause = Caused by:
27 | stackTraceMore = ... {0} more
28 | timeout = {0}s
29 | timeoutTip = This dialog will close itself after certain time. Click or press any key to stop the countdown.
30 |
31 | # Icons
32 | iconmessage = dialog/message
33 | iconinformation = dialog/information
34 | iconwarning = dialog/warning
35 | iconerror = dialog/error
36 | iconconfirmation = dialog/confirmation
37 | iconquestion = dialog/question
38 | iconpassword = dialog/password
39 | iconlogin = dialog/login
40 | iconexception = dialog/exception
41 | icontimeout = dialog/timeout
42 | iconfind = dialog/find
43 | iconreplace = dialog/replace
44 | iconfont = dialog/font
45 | iconcolor = dialog/color
46 | iconfolder = dialog/folder
47 | iconfile = dialog/file
48 | icondate = dialog/date
49 | icontime = dialog/time
50 | iconlogo = dialog/logo
51 |
--------------------------------------------------------------------------------
/ressrc/i18n/dialog.properties:
--------------------------------------------------------------------------------
1 | # Titles
2 | message = Message
3 | information = Information
4 | warning = Warning
5 | error = Error
6 | confirmation = Confirmation
7 | question = Question
8 | password = Password
9 | login = Login
10 | exception = Exception
11 |
12 | # Options
13 | ok = Ok
14 | cancel = Cancel
15 | yes = Yes
16 | no = No
17 | loginok = Login
18 | logincancel = Exit
19 | details = Details
20 |
21 | #Labels
22 | loginUsername = Username:
23 | loginPassword = Password:
24 | stackTraceNative = Native Method
25 | stackTraceUnknown = Unknown Source
26 | stackTraceCause = Caused by:
27 | stackTraceMore = ... {0} more
28 | timeout = {0}s
29 | timeoutTip = This dialog will close itself after certain time. Click or press any key to stop the countdown.
30 |
31 | # Icons
32 | iconmessage = dialog/message
33 | iconinformation = dialog/information
34 | iconwarning = dialog/warning
35 | iconerror = dialog/error
36 | iconconfirmation = dialog/confirmation
37 | iconquestion = dialog/question
38 | iconpassword = dialog/password
39 | iconlogin = dialog/login
40 | iconexception = dialog/exception
41 | icontimeout = dialog/timeout
42 | iconfind = dialog/find
43 | iconreplace = dialog/replace
44 | iconfont = dialog/font
45 | iconcolor = dialog/color
46 | iconfolder = dialog/folder
47 | iconfile = dialog/file
48 | icondate = dialog/date
49 | icontime = dialog/time
50 | iconlogo = dialog/logo
51 |
--------------------------------------------------------------------------------
/src/org/svetovid/demo/MaxArray.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.demo;
18 |
19 | import org.svetovid.Svetovid;
20 |
21 | public class MaxArray {
22 |
23 | public static void main(String[] args) {
24 |
25 | // Ask for an array of numbers
26 | double[] numbers = Svetovid.in.readDoubleArray("Please enter the numbers:");
27 |
28 | // Find the maximum
29 | double maximum = Double.NEGATIVE_INFINITY;
30 | for (double number : numbers) {
31 | if (number > maximum) {
32 | maximum = number;
33 | }
34 | }
35 |
36 | // Print the result
37 | Svetovid.out.println("Maximum number:", maximum);
38 | Svetovid.out.println(numbers);
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/exception.svg:
--------------------------------------------------------------------------------
1 |
2 |
26 |
--------------------------------------------------------------------------------
/doc/sr/primeri/SumaBrojevaIzFajla.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Ovo je primer citanja brojeva iz fajla i njihovog sumiranja. Brojevi u fajlu
3 | * mogu biti rasporedjeni bilo kako, bitno je samo da su razdvojeni prelomima
4 | * redova, razmacima ili tabulatorima. Mogu postojati i prazni redovi,
5 | * visestruki razmaci ili bilo kakve kombinacije separatora, program ce raditi
6 | * kako treba. Jedino je bitno da su u fajlu sve brojevi.
7 | *
8 | * Videti primer u datom fajlu 'brojevi.txt'.
9 | */
10 | public class SumaBrojevaIzFajla {
11 |
12 | /** Ime fajla iz kojeg citamo brojeve. */
13 | public static final String IME_FAJLA = "brojevi.txt";
14 |
15 | /** Glavni program. */
16 | public static void main(String[] args) {
17 |
18 | // Ispisujemo prigodnu poruku
19 | Svetovid.out.println("Ucitavamo brojeve iz fajla " + IME_FAJLA);
20 |
21 | // Suma je na pocetku nula
22 | double suma = 0;
23 |
24 | // Ucitamo prvi broj
25 | Double broj = Svetovid.in(IME_FAJLA).readDoubleBoxed();
26 |
27 | // Ako je broj uspesno ucitan
28 | while (broj != null) {
29 |
30 | // Dodajemo ga na sumu
31 | suma = suma + broj;
32 |
33 | // I citamo novi broj
34 | broj = Svetovid.in(IME_FAJLA).readDoubleBoxed();
35 |
36 | }
37 |
38 | // Ispisemo ukupnu sumu na ekran
39 | Svetovid.out.println(suma);
40 |
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/org/svetovid/demo/Factorial.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.demo;
18 |
19 | import org.svetovid.Svetovid;
20 | import org.svetovid.util.Stopwatch;
21 |
22 | public class Factorial {
23 |
24 | public static void main(String[] args) {
25 |
26 | // Ask for n
27 | int n = Svetovid.in.readInt("Factorial of which number would you like me to calculate?");
28 |
29 | // Start the calculation timing
30 | Stopwatch stopwatch = new Stopwatch();
31 |
32 | // Calculate the factorial
33 | long factorial = 1;
34 | for (int i = 2; i < n; i++) {
35 | factorial = i * factorial;
36 | }
37 |
38 | // Print the result
39 | double time = stopwatch.time();
40 | Svetovid.out.println("The factorial is:", factorial);
41 | Svetovid.out.println("It took", time, "seconds to calculate");
42 |
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/org/svetovid/demo/Pyramid.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.demo;
18 |
19 | import org.svetovid.Svetovid;
20 |
21 | public class Pyramid {
22 |
23 | public static void main(String[] args) {
24 |
25 | // Ask for the pyramid size
26 | int size = Svetovid.in.readInt("Please enter the size of the pyramid:");
27 |
28 | // Draw the pyramid layer by layer
29 | for (int i = 1; i <= size; i++) {
30 |
31 | // Add some space to center the pyramid
32 | for (int j = 0; j < size - i; j++) {
33 | Svetovid.out.print(" ");
34 | }
35 |
36 | // Draw the pyramid layer
37 | for (int j = 0; j < i; j++) {
38 | Svetovid.out.print(" *");
39 | }
40 |
41 | // Next layer
42 | Svetovid.out.println();
43 |
44 | }
45 |
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/org/svetovid/demo/Laps.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.demo;
18 |
19 | import org.svetovid.Svetovid;
20 | import org.svetovid.util.Stopwatch;
21 |
22 | public class Laps {
23 |
24 | public static void main(String[] args) {
25 |
26 | // Start the stopwatch
27 | Stopwatch stopwatch = new Stopwatch();
28 |
29 | // Ask for numbers
30 | Double number;
31 | do {
32 | number = Svetovid.in.readDoubleBoxed("Enter a number [ENTER to stop]:");
33 | stopwatch.lap();
34 | } while (number != null);
35 |
36 | // Print the statistics
37 | double[] times = stopwatch.getLapTimes();
38 | Svetovid.out.println("Time it took to enter individual numbers:");
39 | Svetovid.out.println(times);
40 | times = stopwatch.getTotalTimes();
41 | Svetovid.out.println("Total time it took before entering each number:");
42 | Svetovid.out.println(times);
43 |
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/org/svetovid/demo/EvenOdd.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.demo;
18 |
19 | import org.svetovid.Svetovid;
20 |
21 | public class EvenOdd {
22 |
23 | public static void main(String[] args) {
24 |
25 | // Ask for an array of numbers
26 | int[] numbers = Svetovid.in.readIntArray("Please enter the numbers:");
27 |
28 | // Find odd numbers
29 | Svetovid.out.print("Odd numbers are:");
30 | for (int number : numbers) {
31 | if (number % 2 == 1) {
32 | Svetovid.out.print();
33 | Svetovid.out.print(number);
34 | }
35 | }
36 | Svetovid.out.println();
37 |
38 | // Find even numbers
39 | Svetovid.out.print("Even numbers are:");
40 | for (int number : numbers) {
41 | if (number % 2 == 0) {
42 | Svetovid.out.print();
43 | Svetovid.out.print(number);
44 | }
45 | }
46 | Svetovid.out.println();
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/org/svetovid/dialogs/LoginData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.dialogs;
18 |
19 | /**
20 | * Class that holds user name and password.
21 | *
22 | * @author Ivan Pribela
23 | * @version 1.3
24 | */
25 | public class LoginData {
26 |
27 | /**
28 | * User name.
29 | */
30 | public final String name;
31 |
32 | /**
33 | * User password.
34 | */
35 | public final char [] password;
36 |
37 | /**
38 | * Creates a new object that holds specified user name and password.
39 | *
40 | * @param name user name.
41 | * @param password password.
42 | */
43 | public LoginData(String name, char [] password) {
44 | this.name = name;
45 | this.password = password;
46 | }
47 |
48 | /**
49 | * Utility method that wipes the stored password.
50 | */
51 | public void clearPassword() {
52 | if (password != null){
53 | for (int i = 0; i < password.length; i++) {
54 | password[i] = 0;
55 | }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/installers/install-svetovid-lib.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | url="http://svetovid.org/lib/svetovid-lib.jar"
4 | folder='/usr/local/lib'
5 | file='svetovid-lib.jar'
6 | config='/etc/environment'
7 | variable='CLASSPATH'
8 |
9 | # Check if administrator
10 | if [ $(id -u) -ne 0 ]; then
11 | echo "Please run as administrator/super user"
12 | exit
13 | fi
14 |
15 | if [ -f "./$file" ]; then
16 | echo "Found $file in current folder, will use that"
17 | localfile=1
18 | else
19 | # Check if curl is available
20 | curl -V >/dev/null 2>&1
21 | if [ $? -ne 0 ]; then
22 | echo "Curl is not available, can not download svetovid-lib.jar"
23 | echo "You can either install curl, or put $file in this folder."
24 | exit
25 | fi
26 | fi
27 |
28 | # Check if sed is available
29 | sed --version >/dev/null 2>&1
30 | if [ $? -ne 0 ]; then
31 | echo "Sed is not available, CLASSPATH will be just appended. This may cause problems if installed multiple times."
32 | nosed=1
33 | fi
34 |
35 | # Create the folder
36 | mkdir -p "$folder"
37 |
38 | if [ -z $localfile ]; then
39 | # Download the library
40 | echo "Downloading library from $url"
41 | curl -fsL "$url" -o "$folder/$file"
42 | if [ $? -ne 0 ]; then
43 | echo "Failed to download Svetovid library; please check url"
44 | exit
45 | fi
46 | else
47 | # copy local file
48 | cp "./$file" "$folder/$file"
49 | echo "Moved local file $file to $folder"
50 | fi
51 |
52 | # Set the class path
53 | value="$folder/$file:."
54 | if [ -z $nosed ] && grep -q "$variable" "$config" 2>/dev/null; then
55 | sed -i "s|$variable=.*|$variable=\"$value\"|" "$config"
56 | else
57 | echo "$variable=\"$value\"" >> "$config"
58 | fi
59 |
60 | echo "CLASSPATH set to use svetovid-lib; please re-login for the changes to be applied."
61 |
--------------------------------------------------------------------------------
/doc/sr/ucitavanje-i-ispisivanje.markdown:
--------------------------------------------------------------------------------
1 | Učitavanje i ispisivanje
2 | ========================
3 |
4 | Učitavanje osnovnih tipova podataka sa tastature, odnosno standardnog ulaza, se
5 | može jednostavno postići pomoću metoda iz `Svetovid.in`:
6 |
7 | int a = Svetovid.in.readInt();
8 | int b = Svetovid.in.readInt();
9 |
10 | Metodima se može proslediti i string sa porukom koja će biti prikazana
11 | korisniku:
12 |
13 | int a = Svetovid.in.readInt("Unesite jedan broj:");
14 | int b = Svetovid.in.readInt("Unesite drugi broj:");
15 |
16 | Ispis osnovnih tipova na ekran, odnosno standardni izlaz, je takođe jednostavan
17 | uz korišćenje metoda iz `Svetovid.out`:
18 |
19 | Svetovid.out.println(a + b);
20 |
21 | Prilikom ispisivanja se takođe može proslediti prigodna poruka namenjena
22 | korisniku:
23 |
24 | Svetovid.out.println("Zbir je:", a + b);
25 |
26 | Prilikom učitavanja podataka potrebno je koristiti `read` metod koji odgovara
27 | tipu podataka koji se traži od korisnika. Na primer
28 |
29 | - `readInt` za `int` (cele brojeve)
30 | - `readDouble` za realne brojeve duple preciznosti
31 | - `readBool` za `boolean`,
32 | - `readLong` za `longint` (celi brojevi u većem opsegu vrednosti),
33 |
34 |
35 | Za tip `String` (niz znakova) se najčešće koristi sledeći metod:
36 |
37 | String ceoRed = Svetovid.in.readLine();
38 |
39 | Prilikom ispisivanja nije potrebno uzimati tip podatka za ime metoda,
40 | pošto postoji po jedan `print` metod za svaki od osnovnih tipova
41 | podataka.
42 |
43 | Analogne komande za učitavanje i ispisivanje se mogu naći u okviru klase
44 | `System`, a mogu se koristiti naizmenično sa onima iz klase `Svetovid` bez
45 | ikakvih problema:
46 |
47 | Svetovid.out.println("Prva poruka");
48 | System.out.println("Druga poruka");
49 | Svetovid.out.println("Treća poruka");
50 |
--------------------------------------------------------------------------------
/src/org/svetovid/util/JsonType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.util;
18 |
19 | /**
20 | * Enumeration of all JSON (JavaScript Object Notation) types.
21 | *
22 | * @author Ivan Pribela
23 | */
24 | public enum JsonType {
25 |
26 | /**
27 | * Null literal ({@code null}).
28 | */
29 | NULL("Null"),
30 |
31 | /**
32 | * Boolean literal ({@code true} or {@code false}).
33 | */
34 | BOOLEAN("Boolean"),
35 |
36 | /**
37 | * Number literal.
38 | */
39 | NUMBER("Number"),
40 |
41 | /**
42 | * String literal.
43 | */
44 | STRING("String"),
45 |
46 | /**
47 | * JSON Array.
48 | */
49 | ARRAY("Array"),
50 |
51 | /**
52 | * JSON object.
53 | */
54 | OBJECT("Object"),
55 |
56 | /**
57 | * Unknown JSON type.
58 | */
59 | UNKNOWN("Unknown");
60 |
61 | private String friendlyName;
62 |
63 | private JsonType(String friendlyName) {
64 | this.friendlyName = friendlyName;
65 | }
66 |
67 | @Override
68 | public String toString() {
69 | return friendlyName;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/org/svetovid/io/SvetovidProcess.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.io;
18 |
19 | public class SvetovidProcess {
20 |
21 | public final Process process;
22 | public final SvetovidWriter in;
23 | public final SvetovidReader out;
24 | public final SvetovidReader err;
25 |
26 | public SvetovidProcess(Process process) {
27 | this.process = process;
28 | in = new DefaultSvetovidWriter(process.getOutputStream());
29 | out = new DefaultSvetovidReader(process.getInputStream());
30 | err = new DefaultSvetovidReader(process.getErrorStream());
31 | }
32 |
33 | public String toString() {
34 | return process.toString();
35 | }
36 |
37 | public int waitFor() throws InterruptedException {
38 | return process.waitFor();
39 | }
40 |
41 | public boolean isAlive() {
42 | try {
43 | process.exitValue();
44 | return false;
45 | } catch(IllegalThreadStateException e) {
46 | return true;
47 | }
48 | }
49 |
50 | public int exitValue() {
51 | return process.exitValue();
52 | }
53 |
54 | public void destroy() {
55 | process.destroy();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/org/svetovid/dialogs/Resources.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.dialogs;
18 |
19 | import java.net.URL;
20 | import java.util.HashMap;
21 | import java.util.Map;
22 |
23 | import javax.swing.Icon;
24 | import javax.swing.ImageIcon;
25 |
26 | /**
27 | * This is helper class which contains methods to easily access resources.
28 | *
29 | * @author Ivan Pribela
30 | * @version 1.0
31 | */
32 | public class Resources {
33 |
34 | //----------------------//
35 | // Icon cache subsystem //
36 | //----------------------//
37 |
38 | /**
39 | * Map used to cache icons in application.
40 | */
41 | private static Map icons = new HashMap();
42 |
43 | /**
44 | * Returns icon from the resource named {@code name}. Icon is cached in
45 | * internal map for faster access.
46 | *
47 | * @param name
48 | * name of the icon to be retrieved
49 | * @return icon associated with specified name
50 | */
51 | public static Icon getIcon(String name) {
52 | Icon icon = icons.get(name);
53 | if (icon == null) {
54 | URL url = Resources.class.getClassLoader().getResource("images/" + name + ".png");
55 | icon = new ImageIcon(url);
56 | icons.put(name, icon);
57 | }
58 | return icon;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/installers/uninstall.ps1:
--------------------------------------------------------------------------------
1 | # MIT License
2 |
3 | # Copyright (c) 2023 Dušan Simić
4 |
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy
6 | # of this software and associated documentation files (the "Software"), to deal
7 | # in the Software without restriction, including without limitation the rights
8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | # copies of the Software, and to permit persons to whom the Software is
10 | # furnished to do so, subject to the following conditions:
11 |
12 | # The above copyright notice and this permission notice shall be included in all
13 | # copies or substantial portions of the Software.
14 |
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | # SOFTWARE.
22 |
23 | Function Remove-ValueFromEnvironmentVariable {
24 | param (
25 | [String] $Variable,
26 | [String] $Value,
27 | [String] $Scope
28 | )
29 |
30 | $var = [System.Environment]::GetEnvironmentVariable($Variable, $Scope)
31 | if ($var -ne $null) {
32 | $var = ($var.Split(";") | Where-Object { $_ -ne $Value }) -join ";"
33 | [System.Environment]::SetEnvironmentVariable($Variable, $var, $Scope)
34 | }
35 | }
36 |
37 | $LocalAppDataDirectory = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::LocalApplicationData)
38 | $LibraryDirectory = "$LocalAppDataDirectory\Svetovid Library"
39 | $LibraryFile = "svetovid-lib.jar"
40 | $LibraryPath = "$LibraryDirectory\$LibraryFile"
41 |
42 | Remove-Item $LibraryDirectory -Recurse
43 |
44 | Remove-ValueFromEnvironmentVariable "CLASSPATH" $LibraryPath "User"
45 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/folder.svg:
--------------------------------------------------------------------------------
1 |
2 |
43 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/file.svg:
--------------------------------------------------------------------------------
1 |
2 |
43 |
--------------------------------------------------------------------------------
/src/org/svetovid/demo/Calculator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.demo;
18 |
19 | import org.svetovid.run.Start;
20 |
21 | public class Calculator {
22 |
23 | public static class Inner {
24 | public int add(int a) {
25 | return a + 1;
26 | }
27 | }
28 |
29 | public double add(double a) {
30 | throw new RuntimeException("Missing an argument");
31 | }
32 |
33 | @SuppressWarnings("unused")
34 | private double add(double a, double b) {
35 | return a + b;
36 | }
37 |
38 | public double add(double a, double b, double c) {
39 | return a + b + c;
40 | }
41 |
42 | public double minus(double a) {
43 | return -a;
44 | }
45 |
46 | protected String add(double a, String b) {
47 | return a + b;
48 | }
49 |
50 | public static int sub(int a, int b) {
51 | return a - b;
52 | }
53 |
54 | public static int mul(int a, int b) {
55 | return a * b;
56 | }
57 |
58 | public static void main(String[] arguments) {
59 | // Running this main method has the same result as using the Start class with the following arguments
60 | arguments = new String[] { "org.svetovid.demo.Calculator", "add", "6", "3" };
61 | Start.main(arguments);
62 | arguments = new String[] { "org.svetovid.demo.Calculator$Inner", "add", "6", "3" };
63 | Start.main(arguments);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/doc/sr/primeri/CitanjeFajla.java:
--------------------------------------------------------------------------------
1 | /**
2 | * U ovoj klasi ce biti demonstrirana dva pristupa za ispisivanje svih redova
3 | * jednog fajla na ekran. Prvi primer je direktan i cita fajl red po red, dokle
4 | * god ne dodje do kraja. Drugi koristi pogodnosti Svetovid biblioteke i
5 | * odjednom ucitava sve redove kao niz stringova, i odmah ih ispisuje na ekran
6 | * odgovarajucom komandom. Potencijalana mana ovog drugog pristupa je sto ce se
7 | * svi redovi odjednom naci u memoriji. Dodatna prednost kod prvog pristupa je
8 | * i to sto mozemo lako modifikovati kod tako da se usput odustane od daljeg
9 | * citanja fajla ako smo nasli ono sto smo trazili, ili ako smo nasli neku
10 | * gresku.
11 | */
12 | public class CitanjeFajla {
13 |
14 | /** Cita i ispisuje sve redove fajla na ekran. */
15 | static void citajSveRedove(String imeFajla) {
16 |
17 | /* Radimo dokle god fajl nije prazan */
18 | while (!Svetovid.in(imeFajla).isEmpty()){
19 |
20 | /* Citamo ceo red */
21 | String red = Svetovid.in(imeFajla).readLine();
22 |
23 | /* Ispisujemo procitani red */
24 | Svetovid.out.println(red);
25 |
26 | }
27 |
28 | }
29 |
30 | /** alternativni nacin da ispisemo sve redove fajla. */
31 | static void citajSveRedoveAlt(String imeFajla) {
32 |
33 | /* Koriste se pogodnosti biblioteke za citanje svih redova odjednom */
34 | Svetovid.out.println(Svetovid.in(imeFajla).readAll());
35 |
36 | }
37 |
38 | /** Glavni program koji poziva prethodna dva metoda. */
39 | public static void main(String[] args) {
40 |
41 | // Pitamo korisnika za ime fajla koji korisitmo
42 | String imeFajla = Svetovid.in.readLine("Unesite ime fajla:");
43 |
44 | // Poziv prvog nacina ispisivanja
45 | citajSveRedove(imeFajla);
46 |
47 | // Moramo zatvoriti fajl da bi ga opet citali ispocetka
48 | Svetovid.in(imeFajla).close();
49 |
50 | // Poziv drugog nacina ispisivanja
51 | citajSveRedoveAlt(imeFajla);
52 |
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/res/i18n/dialog_sr.properties:
--------------------------------------------------------------------------------
1 | # Titles
2 | message = \u041f\u043e\u0440\u0443\u043a\u0430
3 | information = \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0458\u0430
4 | warning = \u0423\u043f\u043e\u0437\u043e\u0440\u0435\u045a\u0435
5 | error = \u0413\u0440\u0435\u0448\u043a\u0430
6 | confirmation = \u041f\u043e\u0442\u0432\u0440\u0434\u0430
7 | question = \u041f\u0438\u0442\u0430\u045a\u0435
8 | password = \u041b\u043e\u0437\u0438\u043d\u043a\u0430
9 | login = \u041f\u0440\u0438\u0458\u0430\u0432\u0430
10 | exception = \u0418\u0437\u0443\u0437\u0435\u0442\u0430\u043a
11 |
12 | # Options
13 | ok = \u0423\u0440\u0435\u0434\u0443
14 | cancel = \u041e\u0442\u043a\u0430\u0436\u0438
15 | yes = \u0414\u0430
16 | no = \u041d\u0435
17 | loginok = \u0423\u0440\u0435\u0434\u0443
18 | logincancel = \u0418\u0437\u043b\u0430\u0437
19 | details = \u0414\u0435\u0442\u0430\u0459\u0438
20 |
21 | #Labels
22 | loginUsername = \u041a\u043e\u0440\u0438\u0441\u043d\u0438\u0447\u043a\u043e \u0438\u043c\u0435:
23 | loginPassword = \u041b\u043e\u0437\u0438\u043d\u043a\u0430:
24 | stackTraceNative = \u0421\u0438\u0441\u0442\u0435\u043c\u0441\u043a\u0438 \u043c\u0435\u0442\u043e\u0434
25 | stackTraceUnknown = \u041d\u0435\u043f\u043e\u0437\u043d\u0430\u0442 \u0438\u0437\u0432\u043e\u0440
26 | stackTraceCause = \u0423\u0437\u0440\u043e\u043a:
27 | stackTraceMore = ... \u0458\u043e\u0448 {0}
28 | timeout = {0} s
29 | timeoutTip = \u041e\u0432\u0430\u0458 \u0434\u0438\u0458\u0430\u043b\u043e\u0433 \u045b\u0435 \u0441\u0435 \u0441\u0430\u043c \u0437\u0430\u0442\u0432\u043e\u0440\u0438\u0442\u0438 \u043f\u043e\u0441\u043b\u0435 \u043e\u0434\u0440\u0435\u0452\u0435\u043d\u043e\u0433 \u0432\u0440\u0435\u043c\u0435\u043d\u0430. \u041a\u043b\u0438\u043a\u043d\u0438\u0442\u0435 \u043e\u0432\u0434\u0435 \u0438\u043b\u0438 \u043f\u0440\u0438\u0442\u0438\u0441\u043d\u0438\u0442\u0435 \u0431\u0438\u043b\u043e \u043a\u043e\u0458\u0438 \u0442\u0430\u0441\u0442\u0435\u0440 \u0434\u0430 \u0437\u0430\u0443\u0441\u0442\u0430\u0432\u0438\u0442\u0435 \u043e\u0434\u0431\u0440\u043e\u0458\u0430\u0432\u0430\u045a\u0435.
30 |
31 | # Icons
32 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/time.svg:
--------------------------------------------------------------------------------
1 |
2 |
44 |
--------------------------------------------------------------------------------
/src/org/svetovid/io/StandardOutputStreamProxy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.io;
18 |
19 | import java.io.IOException;
20 | import java.io.OutputStream;
21 |
22 | /**
23 | * Instances of this class serve as proxies for the currently set-up standard
24 | * output stream (see {@link System#out}). If the standard output stream changes
25 | * (through {@link System#setOut(java.io.PrintStream)}) instances of this class
26 | * will forward the output to the new stream.
27 | *
28 | *
29 | * All instances of this class are considered equal.
30 | *
31 | * @author Ivan Pribela
32 | *
33 | * @see System#out
34 | */
35 | public class StandardOutputStreamProxy extends OutputStream {
36 |
37 | public void write(int b) throws IOException {
38 | System.out.write(b);
39 | }
40 |
41 | public void write(byte[] b) throws IOException {
42 | System.out.write(b);
43 | }
44 |
45 | public void write(byte[] b, int off, int len) throws IOException {
46 | System.out.write(b, off, len);
47 | }
48 |
49 | public void flush() throws IOException {
50 | System.out.flush();
51 | }
52 |
53 | public void close() throws IOException {
54 | System.out.close();
55 | }
56 |
57 | public String toString() {
58 | return System.out.toString();
59 | }
60 |
61 | public int hashCode() {
62 | return System.out.hashCode();
63 | }
64 |
65 | public boolean equals(Object obj) {
66 | return (obj != null) && (getClass().equals(obj.getClass()));
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/org/svetovid/dialogs/DefaultDialogFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.dialogs;
18 |
19 | import java.awt.GraphicsEnvironment;
20 | import java.awt.Toolkit;
21 | import java.awt.datatransfer.Clipboard;
22 | import java.util.Locale;
23 |
24 | public class DefaultDialogFactory extends AbstractDialogFactory {
25 |
26 | public DefaultDialogFactory() {
27 | this(Locale.getDefault());
28 | }
29 |
30 | public DefaultDialogFactory(Clipboard clipboard) {
31 | this(Locale.getDefault(), clipboard);
32 | }
33 |
34 | public DefaultDialogFactory(Locale locale) {
35 | this(locale, GraphicsEnvironment.isHeadless() ? null : Toolkit.getDefaultToolkit().getSystemClipboard());
36 | }
37 |
38 | public DefaultDialogFactory(Locale locale, Clipboard clipboard) {
39 | super(locale, clipboard);
40 | }
41 |
42 | @Override
43 | public Locale getLocale() {
44 | return super.getLocale();
45 | }
46 |
47 | @Override
48 | public void setLocale(Locale newValue) {
49 | super.setLocale(newValue);
50 | }
51 |
52 | @Override
53 | public Clipboard getClipboard() {
54 | return super.getClipboard();
55 | }
56 |
57 | @Override
58 | public void setClipboard(Clipboard newValue) {
59 | super.setClipboard(newValue);
60 | }
61 |
62 | public boolean isNewStackTraceStyle() {
63 | return newStackTraceStyle;
64 | }
65 |
66 | public void setNewStackTraceStyle(boolean newValue) {
67 | newStackTraceStyle = newValue;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/org/svetovid/io/StandardErrorStreamProxy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.io;
18 |
19 | import java.io.IOException;
20 | import java.io.OutputStream;
21 |
22 | /**
23 | * Instances of this class serve as proxies for the currently set-up "standard"'
24 | * error output stream (see {@link System#err}). If the "standard" error output
25 | * stream changes (through {@link System#setErr(java.io.PrintStream)}) instances
26 | * of this class will forward the output to the new stream.
27 | *
28 | *
29 | * All instances of this class are considered equal.
30 | *
31 | * @author Ivan Pribela
32 | *
33 | * @see System#err
34 | */
35 | public class StandardErrorStreamProxy extends OutputStream {
36 |
37 | public void write(int b) throws IOException {
38 | System.err.write(b);
39 | }
40 |
41 | public void write(byte[] b) throws IOException {
42 | System.err.write(b);
43 | }
44 |
45 | public void write(byte[] b, int off, int len) throws IOException {
46 | System.err.write(b, off, len);
47 | }
48 |
49 | public void flush() throws IOException {
50 | System.err.flush();
51 | }
52 |
53 | public void close() throws IOException {
54 | System.err.close();
55 | }
56 |
57 | public String toString() {
58 | return System.err.toString();
59 | }
60 |
61 | public int hashCode() {
62 | return System.err.hashCode();
63 | }
64 |
65 | public boolean equals(Object obj) {
66 | return (obj != null) && (getClass().equals(obj.getClass()));
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/color.svg:
--------------------------------------------------------------------------------
1 |
2 |
42 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/timeout.svg:
--------------------------------------------------------------------------------
1 |
2 |
46 |
--------------------------------------------------------------------------------
/src/org/svetovid/util/Release.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.util;
18 |
19 | import java.net.URL;
20 |
21 | public class Release implements Comparable {
22 |
23 | private Version version;
24 | private URL url;
25 |
26 | public Release(Version version, URL url) {
27 | if (version == null) {
28 | throw new IllegalArgumentException("version");
29 | }
30 | this.version = version;
31 | if (url == null) {
32 | throw new IllegalArgumentException("url");
33 | }
34 | this.url = url;
35 | }
36 |
37 | public Version getVersion() {
38 | return version;
39 | }
40 |
41 | public URL getUrl() {
42 | return url;
43 | }
44 |
45 | @Override
46 | public String toString() {
47 | return version + " [" + url + "]";
48 | }
49 |
50 | @Override
51 | public int hashCode() {
52 | return toString().hashCode();
53 | }
54 |
55 | @Override
56 | public boolean equals(Object obj) {
57 | if (obj == null) {
58 | return false;
59 | }
60 | if (!(obj instanceof Release)) {
61 | return false;
62 | }
63 | return compareTo((Release) obj) == 0;
64 | }
65 |
66 | @Override
67 | public int compareTo(Release that) {
68 | int result = this.version.compareTo(that.version);
69 | if (result == 0) {
70 | result = 2 * this.url.toString().compareTo(that.url.toString());
71 | }
72 | return result;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/org/svetovid/demo/LibraryVersions.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.demo;
18 |
19 | import org.svetovid.Svetovid;
20 | import org.svetovid.util.JsonHelper;
21 |
22 | public class LibraryVersions {
23 |
24 | public static void main(String[] args) {
25 |
26 | // Get release info from GitHub
27 | String uri = "https://api.github.com/repos/ivanpribela/svetovid-lib/releases";
28 | Object data = Svetovid.in(uri).readObject();
29 |
30 | // Print
31 | String libraryName = "Svetovid library";
32 | Svetovid.out.println(libraryName);
33 | Svetovid.out.println(libraryName.replaceAll(".", "="));
34 | Svetovid.out.println();
35 |
36 | // Print available versions
37 | for (Object version : JsonHelper.getArray(data, ".")) {
38 |
39 | // Extract the data
40 | String name = JsonHelper.getString(version, "name");
41 | String url = JsonHelper.getString(version, "html_url");
42 |
43 | // Print the information
44 | Svetovid.out.println(name);
45 | Svetovid.out.println(name.replaceAll(".", "-"));
46 | Svetovid.out.println("URL:", url);
47 |
48 | // Print available files
49 | for (Object asset : JsonHelper.getArray(version, "assets")) {
50 | String file = JsonHelper.getString(asset, "name");
51 | String download = JsonHelper.getString(asset, "browser_download_url");
52 | Svetovid.out.println("(" + file + ")\t" + download);
53 | }
54 | Svetovid.out.println();
55 |
56 | }
57 |
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/installers/install.ps1:
--------------------------------------------------------------------------------
1 | # MIT License
2 |
3 | # Copyright (c) 2023 Dušan Simić
4 |
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy
6 | # of this software and associated documentation files (the "Software"), to deal
7 | # in the Software without restriction, including without limitation the rights
8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | # copies of the Software, and to permit persons to whom the Software is
10 | # furnished to do so, subject to the following conditions:
11 |
12 | # The above copyright notice and this permission notice shall be included in all
13 | # copies or substantial portions of the Software.
14 |
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | # SOFTWARE.
22 |
23 | Function Test-EnvironmentVariableContainsValue {
24 | param (
25 | [String] $Variable,
26 | [String] $Value,
27 | [String] $Scope
28 | )
29 |
30 | $var = [System.Environment]::GetEnvironmentVariable($Variable, $Scope)
31 | If ($var -ne $null) {
32 | Return $var -split ";" -contains $Value
33 | }
34 | Return $false
35 | }
36 |
37 | $FileUrl = "https://svetovid.org/lib/svetovid-lib.jar"
38 | $LocalAppDataDirectory = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::LocalApplicationData)
39 | $LibraryDirectory = "$LocalAppDataDirectory\Svetovid Library"
40 | $LibraryFile = "svetovid-lib.jar"
41 | $LibraryPath = "$LibraryDirectory\$LibraryFile"
42 |
43 | If (-Not(Test-Path -Path $LibraryDirectory)) {
44 | New-Item -ItemType Directory -Path $LibraryDirectory
45 | }
46 |
47 | If (-Not(Test-Path -Path $LibraryPath)) {
48 | [Net.ServicePointManager]::SecurityProtocol = "Tls, Tls11, Tls12, Ssl3"
49 | Invoke-WebRequest $FileUrl -OutFile $LibraryPath
50 | }
51 |
52 | If (-Not(Test-EnvironmentVariableContainsValue "CLASSPATH" $LibraryPath "User")) {
53 | [System.Environment]::SetEnvironmentVariable("CLASSPATH", $Env:CLASSPATH + ";$LibraryPath", "User")
54 | }
55 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/confirmation.svg:
--------------------------------------------------------------------------------
1 |
2 |
52 |
--------------------------------------------------------------------------------
/src/org/svetovid/io/StandardInputStreamProxy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.io;
18 |
19 | import java.io.IOException;
20 | import java.io.InputStream;
21 |
22 | /**
23 | * Instances of this class serve as proxies for the currently set-up standard
24 | * input stream (see {@link System#in}). If the standard input stream changes
25 | * (through {@link System#setIn(java.io.InputStream)}) instances of this class
26 | * will request the input from the new stream.
27 | *
28 | *
29 | * All instances of this class are considered equal.
30 | *
31 | * @author Ivan Pribela
32 | *
33 | * @see System#in
34 | */
35 | public class StandardInputStreamProxy extends InputStream {
36 |
37 | public int read() throws IOException {
38 | return System.in.read();
39 | }
40 |
41 | public int read(byte[] b) throws IOException {
42 | return System.in.read(b);
43 | }
44 |
45 | public int read(byte[] b, int off, int len) throws IOException {
46 | return System.in.read(b, off, len);
47 | }
48 |
49 | public long skip(long n) throws IOException {
50 | return System.in.skip(n);
51 | }
52 |
53 | public int available() throws IOException {
54 | return System.in.available();
55 | }
56 |
57 | public boolean markSupported() {
58 | return System.in.markSupported();
59 | }
60 |
61 | public void mark(int readlimit) {
62 | System.in.mark(readlimit);
63 | }
64 |
65 | public void reset() throws IOException {
66 | System.in.reset();
67 | }
68 |
69 | public void close() throws IOException {
70 | System.in.close();
71 | }
72 |
73 | public String toString() {
74 | return System.in.toString();
75 | }
76 |
77 | public int hashCode() {
78 | return System.in.hashCode();
79 | }
80 |
81 | public boolean equals(Object obj) {
82 | return (obj != null) && (getClass().equals(obj.getClass()));
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/message.svg:
--------------------------------------------------------------------------------
1 |
2 |
52 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/information.svg:
--------------------------------------------------------------------------------
1 |
2 |
57 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/find.svg:
--------------------------------------------------------------------------------
1 |
2 |
57 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/replace.svg:
--------------------------------------------------------------------------------
1 |
2 |
57 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/print.svg:
--------------------------------------------------------------------------------
1 |
2 |
58 |
59 |
--------------------------------------------------------------------------------
/src/org/svetovid/demo/WeatherConditions.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.demo;
18 |
19 | import org.svetovid.Svetovid;
20 | import org.svetovid.util.JsonHelper;
21 |
22 | public class WeatherConditions {
23 |
24 | public static final String API_KEY = "";
25 |
26 | public static void main(String[] args) {
27 |
28 | // Ask for location
29 | String location = Svetovid.in.readLine("Display current weather conditions for:");
30 |
31 | // Get the weather info from Open Weather Map
32 | // WARNING: since 2016 openweathermap.org requires an API key,
33 | // please register and acquire one, then set it in the API_KEY constant
34 | String uri = "http://api.openweathermap.org/data/2.5/weather?"
35 | + "units=metric&mode.json&q=" + location + "&appid=" + API_KEY;
36 | Object data = Svetovid.in(uri).readObject();
37 |
38 | // Were there errors?
39 | String error = JsonHelper.getString(data, "message");
40 | if (error != null) {
41 | Svetovid.out.println(error);
42 | return;
43 | }
44 |
45 | // Extract the data
46 | String name = JsonHelper.getString(data, "name");
47 | String weather = JsonHelper.getString(data, "weather[0].main");
48 | Number clouds = JsonHelper.getNumber(data, "clouds.all");
49 | Number temperature = JsonHelper.getNumber(data, "main.temp");
50 | Number humidity = JsonHelper.getNumber(data, "main.humidity");
51 | Number pressure = JsonHelper.getNumber(data, "main.pressure");
52 | Number wind = JsonHelper.getNumber(data, "wind.speed");
53 |
54 | // Print the weather information
55 | Svetovid.out.println(" Location:", name);
56 | Svetovid.out.println(" Weather:", weather);
57 | Svetovid.out.println(" Clouds:", clouds + "%");
58 | Svetovid.out.println("Temperature:", temperature + "\u00b0C");
59 | Svetovid.out.println(" Humidity:", humidity + "%");
60 | Svetovid.out.println(" Pressure:", pressure + " hPa");
61 | Svetovid.out.println(" Wind:", wind + " m/s");
62 |
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/org/svetovid/demo/WeatherForecast.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.demo;
18 |
19 | import org.svetovid.Svetovid;
20 | import org.svetovid.util.JsonHelper;
21 |
22 | public class WeatherForecast {
23 |
24 | public static final String API_KEY = "";
25 |
26 | public static void main(String[] args) {
27 |
28 | // Ask for location
29 | String location = Svetovid.in.readLine("Display weather forecast for:");
30 |
31 | // Get the weather info from Open Weather Map
32 | // WARNING: since 2016 openweathermap.org requires an API key,
33 | // please register and acquire one, then set it in the API_KEY constant
34 | String uri = "http://api.openweathermap.org/data/2.5/forecast?"
35 | + "units=metric&mode.json&q=" + location + "&appid=" + API_KEY;
36 | Object data = Svetovid.in(uri).readObject();
37 |
38 | // Were there errors?
39 | String code = JsonHelper.getString(data, "cod");
40 | if (!"200".equals(code)) {
41 | Svetovid.out.println("Error " + code);
42 | return;
43 | }
44 |
45 | // Print the forecast
46 | String name = JsonHelper.getString(data, "city.name");
47 | Svetovid.out.println("Weather forecast for " + name + ":");
48 | String format = "%s %8s, %4d%% clouds, %5.2f\u00b0C,%4d%% humidity, wind %.2fm/s %n";
49 | for (Object forecast : JsonHelper.getArray(data, "list")) {
50 |
51 | // Extract the data
52 | String time = JsonHelper.getString(forecast, "dt_txt");
53 | String weather = JsonHelper.getString(forecast, "weather[0].main");
54 | Number clouds = JsonHelper.getNumber(forecast, "clouds.all");
55 | Number temperature = JsonHelper.getNumber(forecast, "main.temp");
56 | Number humidity = JsonHelper.getNumber(forecast, "main.humidity");
57 | Number wind = JsonHelper.getNumber(forecast, "wind.speed");
58 |
59 | Svetovid.out.printf(format,
60 | time,
61 | weather,
62 | clouds.longValue(),
63 | temperature.doubleValue(),
64 | humidity.longValue(),
65 | wind.doubleValue()
66 | );
67 |
68 | }
69 |
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Svetovid Lib
2 | ============
3 |
4 | This is a supplement Library for Introductory Programming Courses in Java
5 |
6 | The library is focused on easing input/output operations in Java, which can be
7 | quite hard for novice programmers.
8 |
9 | What's inside
10 | -------------
11 |
12 | The library provides `org.svetovid.io.Svetovid` class that acts as an entry
13 | point to various functionalities of the library. As a convinience, the library
14 | also adds a `Svetovid` class to the default package so that these
15 | functionalities can be accessed without any imports, as easy as the `System`
16 | class.
17 |
18 | Similar to the standard `System` class, the `Svetovid` class provides fields
19 | `in`, `out` and `err` to access standard input, standard output and standard
20 | error output.
21 |
22 |
23 | How to install and use
24 | ----------------------
25 |
26 | The easiest way to use the library is to copy the jar file to the
27 | `lib/ext/` folder of the installed JRE or JDK. There is also a system
28 | wide `lib/ext` folder that can be used. Another way is to add all the
29 | files to the working folder or to the classpath. For more details and
30 | notes about some specific editors and IDEs take a look at the
31 | [documentation folder](doc).
32 |
33 | For usage information checkout the [documentation folder](doc). Some usage
34 | examples are available in `org.svetovid.demo`.
35 |
36 |
37 | Building from source
38 | --------------------
39 |
40 | There are convenient tasks defined in the ant build script
41 | to build the sources, create distributable jar files,
42 | converting the end user documentation from markdown
43 | to HTML, generating the java-doc API, and packing up the
44 | documentation in a zip archive for distribution.
45 |
46 | The default task (which is run if you just start ant with
47 | no parameters) lists the available options and offers to
48 | build everything.
49 |
50 |
51 | Build dependencies
52 | ------------------
53 |
54 | * Java compiler version 7 and up
55 | * `ant` for the supplied build files.
56 | * `ant-contrib` for HTML documentation generation
57 | * `pandoc` for HTML documentation generation
58 |
59 | The library itself should compile successfully with any java
60 | compiler version 7 and up, without any additional
61 | dependencies. It was tested with openjdk7, as well as
62 | Oracle's JDK 8.
63 |
64 | There is a supplied `build.xml` file for `ant`, but the library can
65 | also be compiled directly without any additional tools, or using
66 | alternative tools.
67 |
68 | The ant build has an additional dependency on `ant-contrib`, but only
69 | for the generation of the HTML documentation, all the other task will
70 | perform as expected with a potential warning message.
71 |
72 | The conversion of the user documentation from markdown to HTML is done
73 | with the `pandoc` software, which should be installed on the system
74 | and accessable from the system PATH. For more information about the
75 | software and instalation options check out [Pandoc
76 | website](http://johnmacfarlane.net/pandoc/index.html)
77 |
--------------------------------------------------------------------------------
/doc/sr/instalacija-staro.markdown:
--------------------------------------------------------------------------------
1 | # Stara uputstva za instalacije
2 |
3 | Ova uputstva se ne mogu primenjivati na najnovije verzije
4 | jezika Java, ali su ostavljena ovde za svaki slučaj.
5 |
6 | ## Dodavanje na sistemskom nivou u JVM (do verzije 8)
7 |
8 | *Ova mogućnost je dostupna samo na verzijama Jave do i
9 | uključujući 8. Na kasnijima je izbačen ovaj folder za biblioteke iz
10 | standarda.*
11 |
12 | No verovatno najbolje rešenje je dodavanjem u spisak biblioteka Java
13 | Virtuelne Mašine, pošto će onda biblioteka biti upotrebljiva u svim
14 | direktorijumima bez dodatnih izmena ili posebnih poziva pri
15 | kompajliranju. Potrebno je samo dodati “svetovid-lib.jar” u `lib/ext`
16 | deljeni direktorijum Java Radnih Okruženja. Ove izmene naravno
17 | zahtevaju da imamo administrativni pristup na konkretnom računaru.
18 |
19 | Na Windows operativnom sistemu je to sledeći direktorijum:
20 | `%SystemRoot%\Sun\Java\lib\ext`
21 |
22 | dok je na Linux operativnim sistemima to
23 | `/usr/java/packages/lib/ext`
24 |
25 | [Više detalja o ext direktorijumu](http://docs.oracle.com/javase/tutorial/ext/basics/install.html)
26 |
27 | **Napomena:** Ako je biblioteka instalirana na sistemskom nivou, ta
28 | verzija će biti učitana i koristiće se uvek. Ako se pokušaju korisiti
29 | drugi metodi kao što je navođenje jar-a pri kompajliranju i
30 | otpakivanje u trenutni direktorijum oni će biti ignorisani.
31 |
32 | ## Dodavanje u editor *DrJava*
33 |
34 | *Ovaj editor ne radi ispravno ukoliko nema kompajler za Javu verzije 8
35 | ili ranije, pa više nije među preporučenim izborima.*
36 |
37 | Da bi se u editoru DrJava omogućilo kompajliranje i pokretanje
38 | programa iz panela Interactions, neophodno je nekako obavestiti
39 | editor o postojanju ove dodatne biblioteke.
40 |
41 | Najjednostavnija varijanta je nabavljanje verzije editora u kojoj
42 | je već intergrisana biblioteka "svetovid-lib". Na [sajtu biblioteke](http://svetovid.org/lib/)
43 | se mogu naći ovako pripremljeni jar fajlovi sa najnovijom stabilnom
44 | verzijom biblioteke.
45 |
46 | Naravno moguće je koristiti i neizmenjeni editor. Tada je potrebno
47 | eksplicitno dodati `svetovid-lib.jar` u `Classpath` editora, ili
48 | otpakovati jar u trenutni direktorijum kao što je gore navedeno.
49 |
50 | U okviru editora se ovo postiže na sledeći način:
51 |
52 | - Edit->Preferences->ResourceLocations->Extra Classpath->Add
53 |
54 | Alternativno se radi istog efekta u fajl `.drjava` u korisničkom
55 | direktorijumu može dodati polje
56 |
57 | ```
58 | extra.classpath=putanja/svetovid-lib.jar
59 | ```
60 |
61 | Jednom kad se ovo postavi u editoru, podešavanja će važiti za sve
62 | programe koji se pokreću u njemu. Ovo je vrlo pogodno rešenje pošto ne
63 | zahteva administrativne privilegije, jer jar fajl može biti bilo gde
64 | na sistemu.
65 |
66 | Ako se koriti metod za dodavanje na sistemskom nivou, programi koji
67 | koriste Svetovid-lib će se kompajlirati uspešno u editoru, ali panel
68 | Interactions će prijavljivati grešku, pošto DrJava, nažalost, ne uzima u
69 | obzir deljeni ext direktorijum pri pokretanju.
70 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/warning.svg:
--------------------------------------------------------------------------------
1 |
2 |
63 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/login.svg:
--------------------------------------------------------------------------------
1 |
2 |
62 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/font.svg:
--------------------------------------------------------------------------------
1 |
2 |
64 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/password.svg:
--------------------------------------------------------------------------------
1 |
2 |
67 |
--------------------------------------------------------------------------------
/src/org/svetovid/util/Stopwatch.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.util;
18 |
19 | import java.util.ArrayList;
20 | import java.util.List;
21 |
22 | public class Stopwatch {
23 |
24 | private long startTime;
25 | private long pauseTime;
26 | private long lapTime;
27 | private long pauseLength;
28 | private long lapPauseLength;
29 | private int timesPaused;
30 | private List laps = new ArrayList<>();
31 |
32 | public Stopwatch() {
33 | this(true);
34 | }
35 |
36 | public Stopwatch(boolean autoStart) {
37 | startTime = System.currentTimeMillis();
38 | pauseTime = startTime;
39 | lapTime = startTime;
40 | pauseLength = 0;
41 | lapPauseLength = 0;
42 | timesPaused = 0;
43 | if (!autoStart) {
44 | timesPaused++;
45 | }
46 | }
47 |
48 | public void pause() {
49 | if (timesPaused == 0) {
50 | pauseTime = System.currentTimeMillis();
51 | }
52 | timesPaused++;
53 | }
54 |
55 | public void resume() {
56 | if (timesPaused > 0) {
57 | timesPaused--;
58 | if (timesPaused == 0) {
59 | pauseLength = pauseLength + (System.currentTimeMillis() - pauseTime);
60 | lapPauseLength = lapPauseLength + (System.currentTimeMillis() - pauseTime);
61 | }
62 | }
63 | }
64 |
65 | public boolean isPaused() {
66 | return timesPaused > 0;
67 | }
68 |
69 | public double time() {
70 | long now = isPaused() ? pauseTime : System.currentTimeMillis();
71 | long time = now - startTime - pauseLength;
72 | return time / 1000.0;
73 | }
74 |
75 | public double lap() {
76 | long now = isPaused() ? pauseTime : System.currentTimeMillis();
77 | long time = now - lapTime - lapPauseLength;
78 | lapTime = now;
79 | lapPauseLength = 0;
80 | laps.add(time);
81 | return time / 1000.0;
82 | }
83 |
84 | public double[] getLapTimes() {
85 | int n = laps.size();
86 | double[] result = new double[n];
87 | for (int i = 0; i < n; i++) {
88 | result[i] = laps.get(i) / 1000.0;
89 | }
90 | return result;
91 | }
92 |
93 | public double[] getTotalTimes() {
94 | int n = laps.size();
95 | long sum = 0;
96 | double[] result = new double[n];
97 | for (int i = 0; i < n; i++) {
98 | sum = sum + laps.get(i);
99 | result[i] = sum / 1000.0;
100 | }
101 | return result;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/logo.svg:
--------------------------------------------------------------------------------
1 |
2 |
71 |
--------------------------------------------------------------------------------
/src/org/svetovid/io/DefaultSvetovidReader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.io;
18 |
19 | import java.io.BufferedReader;
20 | import java.io.IOException;
21 | import java.io.InputStream;
22 | import java.io.InputStreamReader;
23 | import java.io.Reader;
24 | import java.io.StringReader;
25 | import java.io.UnsupportedEncodingException;
26 |
27 | import org.svetovid.Svetovid;
28 |
29 | /**
30 | * This class provides a most commonly used implementation for the
31 | * SvetovidReader interface.
32 | *
33 | * @author Ivan Pribela
34 | *
35 | * @see AbstractSvetovidReader
36 | * @see SvetovidReader
37 | */
38 | public class DefaultSvetovidReader extends AbstractSvetovidReader {
39 |
40 | protected BufferedReader reader;
41 |
42 | /**
43 | * Creates a new {@link SvetovidReader} that uses the specified reader for
44 | * input.
45 | *
46 | * @param in
47 | * the reader to use for input
48 | */
49 | public DefaultSvetovidReader(BufferedReader in) {
50 | if (in == null) {
51 | throw new IllegalArgumentException("in");
52 | }
53 | reader = in;
54 | }
55 |
56 | /**
57 | * Creates a new {@link SvetovidReader} that uses the specified reader for
58 | * input.
59 | *
60 | * @param in
61 | * the reader to use for input
62 | */
63 | public DefaultSvetovidReader(Reader in) {
64 | reader = new BufferedReader(in);
65 | }
66 |
67 | /**
68 | * Creates a new {@link SvetovidReader} that uses the specified input stream
69 | * for input.
70 | *
71 | * @param in
72 | * the input stream to use for input
73 | */
74 | public DefaultSvetovidReader(InputStream in) {
75 | try {
76 | reader = new BufferedReader(new InputStreamReader(in, Svetovid.CHARSET_NAME));
77 | } catch (UnsupportedEncodingException e) {
78 | reader = new BufferedReader(new InputStreamReader(in));
79 | }
80 | }
81 |
82 | /**
83 | * Creates a new {@link SvetovidReader} that uses the specified string for
84 | * input.
85 | *
86 | * @param in
87 | * the string to use for input
88 | */
89 | public DefaultSvetovidReader(String in) {
90 | reader = new BufferedReader(new StringReader(in));
91 | }
92 |
93 | @Override
94 | public void close() throws SvetovidIOException {
95 | super.close();
96 | try {
97 | reader.close();
98 | lastException = null;
99 | } catch (IOException e) {
100 | wrapUpIOException(e);
101 | }
102 | }
103 |
104 | @Override
105 | protected String doReadLine() throws IOException {
106 | return reader.readLine();
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/src/org/svetovid/io/DefaultSvetovidWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.io;
18 |
19 | import java.io.BufferedWriter;
20 | import java.io.IOException;
21 | import java.io.OutputStream;
22 | import java.io.OutputStreamWriter;
23 | import java.io.UnsupportedEncodingException;
24 | import java.io.Writer;
25 |
26 | import org.svetovid.Svetovid;
27 |
28 | /**
29 | * This class provides a most commonly used implementation for the
30 | * SvetovidWriter interface.
31 | *
32 | * @author Ivan Pribela
33 | *
34 | * @see AbstractSvetovidWriter
35 | * @see SvetovidWriter
36 | */
37 | public class DefaultSvetovidWriter extends AbstractSvetovidWriter {
38 |
39 | protected BufferedWriter writer;
40 |
41 | /**
42 | * Creates a new {@link SvetovidWriter} that outputs to the specified
43 | * writer.
44 | *
45 | * @param out
46 | * the writer to use for output
47 | */
48 | public DefaultSvetovidWriter(BufferedWriter out) {
49 | if (out == null) {
50 | throw new IllegalArgumentException("out");
51 | }
52 | writer = out;
53 | }
54 |
55 | /**
56 | * Creates a new {@link SvetovidWriter} that outputs to the specified
57 | * writer.
58 | *
59 | * @param out
60 | * the writer to use for output
61 | */
62 | public DefaultSvetovidWriter(Writer out) {
63 | writer = new BufferedWriter(out);
64 | }
65 |
66 | /**
67 | * Creates a new {@link SvetovidWriter} that outputs to the specified output
68 | * stream.
69 | *
70 | * @param out
71 | * the output stream to use for output
72 | */
73 | public DefaultSvetovidWriter(OutputStream out) {
74 | try {
75 | writer = new BufferedWriter(new OutputStreamWriter(out, Svetovid.CHARSET_NAME));
76 | } catch (UnsupportedEncodingException e) {
77 | writer = new BufferedWriter(new OutputStreamWriter(out));
78 | }
79 | }
80 |
81 | @Override
82 | public void close() throws SvetovidIOException {
83 | super.close();
84 | try {
85 | writer.flush();
86 | } catch (IOException e) {
87 | wrapUpIOException(e);
88 | }
89 | try {
90 | writer.close();
91 | } catch (IOException e) {
92 | wrapUpIOException(e);
93 | }
94 | }
95 |
96 | @Override
97 | public void doPrint(String value) throws IOException {
98 | if (value == null) {
99 | value = Svetovid.NULL_STRING;
100 | }
101 | writer.write(value, 0, value.length());
102 | }
103 |
104 | @Override
105 | public void doFlush() throws IOException {
106 | writer.flush();
107 | }
108 |
109 | @Override
110 | public void doPrintln(String value) throws IOException {
111 | doPrint(value);
112 | writer.newLine();
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/src/org/svetovid/io/SvetovidIOException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.io;
18 |
19 | import java.io.IOException;
20 |
21 | import org.svetovid.SvetovidException;
22 |
23 | /**
24 | * Signals that an I/O exception of some sort has occurred. This class is the
25 | * general class of exceptions produced by failed or interrupted I/O operations.
26 | *
27 | * @author Ivan Pribela
28 | *
29 | * @see SvetovidReader
30 | * @see SvetovidWriter
31 | */
32 | public class SvetovidIOException extends SvetovidException {
33 |
34 | private static final long serialVersionUID = -4381176842757568440L;
35 |
36 | /**
37 | * Constructs a {@code SvetovidIOException} with the specified message.
38 | *
39 | * @param messageKey
40 | * The resource bundle key of the detail message, which is saved
41 | * for later retrieval by the {@link #getMessage()} method
42 | * @param messageArguments
43 | * Optional arguments for formatting of the detail message
44 | */
45 | public SvetovidIOException(String messageKey, Object... messageArguments) {
46 | super(messageKey, messageArguments);
47 | }
48 |
49 | /**
50 | * Constructs a {@code SvetovidIOException} with the specified detail
51 | * message and cause.
52 | *
53 | *
54 | * Note that the detail message associated with {@code cause} is not
55 | * automatically incorporated into this exception's detail message.
56 | *
57 | * @param messageKey
58 | * The resource bundle key of the detail message, which is saved
59 | * for later retrieval by the {@link #getMessage()} method
60 | * @param cause
61 | * The cause, which is saved for later retrieval by the
62 | * {@link #getCause()} method. A null value is permitted, and
63 | * indicates that the cause is nonexistent or unknown.
64 | * @param messageArguments
65 | * Optional arguments for formatting of the detail message
66 | */
67 | public SvetovidIOException(String messageKey, Throwable cause,
68 | Object... messageArguments) {
69 | super(messageKey, cause, messageArguments);
70 | }
71 |
72 | /**
73 | * Constructs a {@code SvetovidIOException} with the specified cause.
74 | *
75 | *
76 | * Note that the detail message associated with {@code cause} is not
77 | * automatically incorporated into this exception's detail message, but a
78 | * generic one is used instead.
79 | *
80 | * @param messageKey
81 | * The resource bundle key of the detail message, which is saved
82 | * for later retrieval by the {@link #getMessage()} method
83 | * @param cause
84 | * The cause, which is saved for later retrieval by the
85 | * {@link #getCause()} method. A null value is permitted, and
86 | * indicates that the cause is nonexistent or unknown.
87 | */
88 | public SvetovidIOException(String messageKey, IOException cause) {
89 | super(messageKey, cause, cause.getMessage());
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/org/svetovid/util/SvetovidJsonException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.util;
18 |
19 | import org.svetovid.SvetovidException;
20 |
21 | /**
22 | * Signals that an error occurred while working with JSON objects.
23 | *
24 | * @author Ivan Pribela
25 | */
26 | public class SvetovidJsonException extends SvetovidException {
27 |
28 | private static final long serialVersionUID = 7914127454669473840L;
29 |
30 | /**
31 | * Constructs a {@code SvetovidJsonException} with the specified message.
32 | *
33 | * @param requestedType
34 | * The JSON type to which the object could not be cast
35 | * @param actualType
36 | * The type of the object found
37 | * @param cause
38 | * The cause, which is saved for later retrieval by the
39 | * {@link #getCause()} method. A null value is permitted, and
40 | * indicates that the cause is nonexistent or unknown.
41 | */
42 | public SvetovidJsonException(JsonType requestedType, Class> actualType,
43 | Throwable cause) {
44 | super("Cast", cause, requestedType.toString(),
45 | actualType.getSimpleName());
46 | }
47 |
48 | /**
49 | * Constructs a {@code SvetovidJsonException} with the specified message.
50 | *
51 | * @param requestedType
52 | * The JSON type to which the object could not be cast
53 | * @param actualType
54 | * The type of the object found
55 | */
56 | public SvetovidJsonException(JsonType requestedType, Class> actualType) {
57 | super("Cast", requestedType.toString(),
58 | actualType.getSimpleName());
59 | }
60 |
61 | /**
62 | * Constructs a {@code SvetovidJsonException} with the specified message.
63 | *
64 | * @param requestedType
65 | * The JSON type to which the object could not be cast
66 | * @param actualType
67 | * The type of the object found
68 | * @param path
69 | * JSON path that was used
70 | * @param cause
71 | * The cause, which is saved for later retrieval by the
72 | * {@link #getCause()} method. A null value is permitted, and
73 | * indicates that the cause is nonexistent or unknown.
74 | */
75 | public SvetovidJsonException(JsonType requestedType, Class> actualType,
76 | String path, Throwable cause) {
77 | super("Path", cause, requestedType.toString(),
78 | actualType.getSimpleName(), path);
79 | }
80 |
81 | /**
82 | * Constructs a {@code SvetovidJsonException} with the specified message.
83 | *
84 | * @param requestedType
85 | * The JSON type to which the object could not be cast
86 | * @param actualType
87 | * The type of the object found
88 | * @param path
89 | * JSON path that was used
90 | */
91 | public SvetovidJsonException(JsonType requestedType, Class> actualType, String path) {
92 | super("Path", requestedType.toString(),
93 | actualType.getSimpleName(), path);
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/error.svg:
--------------------------------------------------------------------------------
1 |
2 |
76 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/question.svg:
--------------------------------------------------------------------------------
1 |
2 |
78 |
--------------------------------------------------------------------------------
/src/org/svetovid/util/CompoundList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.util;
18 |
19 | import java.util.AbstractList;
20 | import java.util.ArrayList;
21 | import java.util.List;
22 |
23 | public class CompoundList extends AbstractList {
24 |
25 | private List> lists = new ArrayList<>();
26 |
27 | public CompoundList() {
28 | }
29 |
30 | @SafeVarargs
31 | public CompoundList(List... lists) {
32 | for (List list : lists) {
33 | this.lists.add(list);
34 | }
35 | }
36 |
37 | public List getSublist(int index) {
38 | return lists.get(index);
39 | }
40 |
41 | public void setSublist(int index, List list) {
42 | lists.set(index, list);
43 | }
44 |
45 | public int addSublist(List list) {
46 | lists.add(list);
47 | return lists.size() - 1;
48 | }
49 |
50 | public int insertSublist(int index, List list) {
51 | lists.add(index, list);
52 | return index;
53 | }
54 |
55 | public List removeSublist(int index) {
56 | return lists.remove(index);
57 | }
58 |
59 | @Override
60 | public int size() {
61 | int size = 0;
62 | for (List list : lists) {
63 | if (list == null) {
64 | continue;
65 | }
66 | size = size + list.size();
67 | }
68 | return size;
69 | }
70 |
71 | @Override
72 | public E get(int index) {
73 | if (index < 0) {
74 | throw new IndexOutOfBoundsException("Index: " + index);
75 | }
76 | int totalSize = 0;
77 | for (List list : lists) {
78 | if (list == null) {
79 | continue;
80 | }
81 | int size = list.size();
82 | if (index < size) {
83 | return list.get(index);
84 | }
85 | index = index - size;
86 | totalSize = totalSize + size;
87 | }
88 | throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + totalSize);
89 | }
90 |
91 | @Override
92 | public Object[] toArray() {
93 | Object[][] arrays = new Object[lists.size()][];
94 | int size = 0;
95 | for (int i = 0; i < lists.size(); i++) {
96 | List list = lists.get(i);
97 | if (list == null) {
98 | continue;
99 | }
100 | arrays[i] = list.toArray();
101 | size = size + arrays[i].length;
102 | }
103 | Object[] array = new Object[size];
104 | int index = 0;
105 | for (Object[] arr : arrays) {
106 | System.arraycopy(arr, 0, array, index, arr.length);
107 | index = index + arr.length;
108 | }
109 | return array;
110 | }
111 |
112 | @SuppressWarnings("unchecked")
113 | @Override
114 | public T[] toArray(T[] a) {
115 | Object[] array = toArray();
116 | if (a.length < array.length) {
117 | return (T[]) array;
118 | }
119 | System.arraycopy(array, 0, a, 0, array.length);
120 | return a;
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/date.svg:
--------------------------------------------------------------------------------
1 |
2 |
73 |
--------------------------------------------------------------------------------
/ressrc/images/dialog/.all.svg:
--------------------------------------------------------------------------------
1 |
2 |
55 |
--------------------------------------------------------------------------------
/CHANGES:
--------------------------------------------------------------------------------
1 | Changes from 0.5 to 0.5.1
2 | =========================
3 |
4 | Changes:
5 | --------
6 |
7 | * Documentation update, instalation instructions in Serbian expanded and reorganised
8 |
9 |
10 | Changes from 0.4.1 to 0.5
11 | =========================
12 |
13 | Changes:
14 | --------
15 |
16 | * Added installer and uninstaller scripts
17 |
18 | * Revamped icons for dialogs.
19 |
20 | * Updated weather demos.
21 |
22 |
23 |
24 | Changes from 0.4 to 0.4.1
25 | =========================
26 |
27 | Changes:
28 | --------
29 |
30 | * SvetovidReader and SvetovidWriter can now be used in try-with-resources
31 |
32 | * IO library, added readLine() method to StandardSvetovidReader
33 | that prompts some text and returns a default value on empty string
34 |
35 | * IO library, when searching for files to open, they are first searched
36 | relative to the calling class, and only if not found relative to the
37 | working direcctory
38 |
39 | * IO library, Option readFromNewLine is now setup according to the environment
40 | variable 'svetovid.readFromNewLine'
41 |
42 |
43 |
44 | Changes from 0.3 to 0.4
45 | =======================
46 |
47 | Changes:
48 | --------
49 |
50 | * Replaced icons for dialogs with new custom created ones.
51 |
52 | Fixed bugs:
53 | -----------
54 |
55 | * Unexpected headless exceptions when running in headless environments.
56 |
57 |
58 |
59 | Changes from 0.2 to 0.3
60 | =======================
61 |
62 | Changes that could break compatibility:
63 | ---------------------------------------
64 |
65 | * Significant changes to IO library, both interfaces and implementations.
66 |
67 | New features:
68 | -------------
69 |
70 | * IO library, added printf() method similar to standard Java
71 | PrintStream.printf() method.
72 |
73 | * IO library, support for reading and writting JSON.
74 |
75 | * IO library, Added methods to check whether readers and writers can be
76 | successfully created.
77 |
78 | * IO library, spawn new processes and comunicate with them using IO library
79 | readers and writers.
80 |
81 | * Version class for parsing of version strings and vesion comparison.
82 |
83 | * Currently running operating system discovery.
84 |
85 | * Discovery of Java installations currently present on the operating system.
86 |
87 | * The library is now an OSGi bundle.
88 |
89 | Other changes:
90 | --------------
91 |
92 | * Internationalized exceptions and messages across the whole library.
93 |
94 | * IO library, exception throwing is now optional and configurable via
95 | the throwingExceptions property on readers and writers.
96 |
97 | * IO library, customized null string rendering.
98 |
99 | * IO library, reimplemented various parts to be more efficient.
100 |
101 | * IO library, auto flush is now deafult setting for standard writers.
102 |
103 | * Main class now prints out the currently installed version and checks for any
104 | newer versions.
105 |
106 | * Added demos for JSON reading.
107 |
108 | * Added more demos for IO library.
109 |
110 | Fixed bugs:
111 | -----------
112 |
113 | * IO library, various bug fixes.
114 |
115 |
116 |
117 | Changes from 0.1 to 0.2
118 | =======================
119 |
120 | Changes that could break compatibility:
121 | ---------------------------------------
122 |
123 | * Renamed all writeXxx() methods to printXxx() to be interchangable with
124 | standard Java IO library.
125 |
126 | Other changes:
127 | --------------
128 |
129 | * The library is now Java 1.7 compliant.
130 |
131 | * All files now use UTF-8 encoding.
132 |
133 | * Added HTML documentation
134 |
135 |
136 |
137 | Changes from 0.0 to 0.1
138 | =======================
139 |
140 | New features:
141 | -------------
142 |
143 | * Library for simplifying textual input and output.
144 |
145 | * Support for time measurement.
146 |
147 | * Support for running any method or class, even without main() a method.
148 |
149 | * Shorthand access to IO library from default package.
150 |
151 | * Dialogs library for display of multilingual dialogs.
152 |
153 | * Demos for IO library, stopwatch and start.
154 |
155 | Other changes:
156 | --------------
157 |
158 | * Added documentation for the libraries.
159 |
160 | Fixed bugs:
161 | -----------
162 |
163 | * Null reference problem in IO library.
164 |
--------------------------------------------------------------------------------
/doc/sr/rad-sa-fajlovima.markdown:
--------------------------------------------------------------------------------
1 | Rad sa fajlovima
2 | ================
3 |
4 | Čitanje iz fajla
5 | ----------------
6 |
7 | Čitanje podataka iz tekstualnih fajlova je vrlo slično čitanju podataka sa
8 | standardnog ulaza, [odnosno tastature](ucitavanje-i-ispisivanje.markdown).
9 | Jedina razlika je u tome što se navodi ime fajla iz kojeg se čitaju podaci:
10 |
11 | ```java
12 | int broj1 = Svetovid.in("ulazni.txt").readInt();
13 | int broj2 = Svetovid.in("ulazni.txt").readInt();
14 | int rezultat = broj1 + broj2;
15 | ```
16 |
17 | Fajl će automatski biti otvoren prilikom prvog čitanja u okviru programa, a
18 | čitanje podataka će početi od početka fajla. Ako je fajl već ranije bio otvoren
19 | u okviru programa, čitanje će se nastaviti sa onog mesta na kojem se prethodni
20 | put stalo, odnosno biće učitan naredni podatak.
21 |
22 | Ako je potrebno pročitati sve podatke iz tekstualnog fajla, najjednostavniji
23 | način je pomoću `while` petlje i `hasMore()` metoda:
24 |
25 | ```java
26 | double suma = 0;
27 | String ulaz = "ulazni.txt";
28 | while (Svetovid.in(ulaz).hasMore()) {
29 | double broj = Svetovid.in(ulaz).readDouble();
30 | suma = suma + broj;
31 | }
32 | Svetovid.out.println(suma);
33 | ```
34 |
35 | Kada `hasMore()` metod vrati `false` u fajlu više nema podataka.
36 | Postoji i analogan metod `isEmpty()`.
37 |
38 | Ako je potrebno ponovo pročitati podatke od početka fajla, potrebno je
39 | prvo zatvoriti fajl:
40 |
41 | Svetovid.in("ulazni.txt").close();
42 |
43 | Posle zatvaranja fajla, dalje čitanje podataka će automatski otvoriti fajl i
44 | krenuti od njegovog početka. Ako se fajl dalje neće koristiti, nije potrebno
45 | eksplicitno ga zatvoriti pošto se svi otvoreni fajlovi automatski zatvaraju na
46 | kraju rada programa.
47 |
48 | Pre čitanja je moguće proveriti i da li je fajl dostupan za čitanje
49 | (odnosno da li postoji i da li imamo prava da ga čitamo) koristeći metod
50 | `Svetovid.testIn`. Na primer:
51 |
52 | ```java
53 | if (Svetovid.testIn("ulazni.txt")) {
54 | // citanje fajla
55 | } else {
56 | Svetovid.out.println("Fajl nije dostupan za citanje");
57 | }
58 | ```
59 |
60 |
61 | Pisanje u fajl
62 | --------------
63 |
64 | Upisivanje podataka u tekstualni fajl je vrlo slično ispisivanju podataka na
65 | standardni izlaz, [odnosno ekran](ucitavanje-i-ispisivanje.markdown). Jedina
66 | razlika je u tome što se navodi ime fajla u koji se podaci upisuju:
67 |
68 | ```java
69 | Svetovid.out("izlazni.txt").println("Poruka");
70 | ```
71 |
72 | Ako navedeni fajl nije postojao, automatski će biti napravljen, a ako je fajl
73 | već postojao, sav njegov sadržaj će biti zamenjen ovim tekstom. Svako naredno
74 | pisanje u isti fajl će zadržati njegov prethodni sadržaj, odnosno upisivaće
75 | naredni podatak u nastavku.
76 |
77 | ```java
78 | Svetovid.out("izlazni.txt").println("Malo duža poruka");
79 | Svetovid.out("izlazni.txt").println("u dva reda");
80 | ```
81 |
82 | Ukoliko želimo da u već postojećem fajlu zadržimo sadržaj koji je postojao pre
83 | pokretanja programa i samo dopišemo nove podatke na kraj, to možemo lako uraditi
84 | korišćenjem `append` umesto `out` na sledeći način:
85 |
86 | ```java
87 | Svetovid.append("izlazni.txt").println("Nastavak poruke");
88 | ```
89 |
90 | Izlazni fajl se može eksplicitno zatvoriti sa
91 |
92 | ```java
93 | Svetovid.out("izlazni.txt").close();
94 | ```
95 |
96 | Svi fajlovi otvoreni korišćenjem ove biblioteke se automatski
97 | zatvaraju na kraju rada programa, tako da često nije neophodno
98 | eksplicitno ih zatvarati. Međutim budući da se relativno često može
99 | desiti da su fajlovi potrebni drugim programa pre nego što naš završi
100 | sa radom (naročito čest slučaj kod grafičkih programa) uglavnom se
101 | preporučuje eksplicitno zatvaranje fajla čim je završeno pisanje u
102 | njega.
103 |
104 | Analogno sa čitanjem, moguće je proveriti da li je fajl dostupan za pisanje
105 | (odnosno da li postoji i da li imamo prava da pišemo u njega) koristeći metod
106 | `Svetovid.testOut`. Na primer:
107 |
108 | ```java
109 | if (Svetovid.testOut("izlaz.txt")) {
110 | // pisanje u fajl
111 | } else {
112 | Svetovid.out.println("Nije moguce pisati u fajl");
113 | }
114 | ```
115 |
--------------------------------------------------------------------------------
/ressrc/i18n/exception_sr.properties:
--------------------------------------------------------------------------------
1 | # Stack trace messages and fragments
2 |
3 | StackTrace.Thread = Изузетак у нити "{0}"
4 | StackTrace.Main = {0}: {1}
5 | StackTrace.Cause = Узрок: {0}: {1}
6 | StackTrace.Supressed = Потиснут: {0}: {1}
7 | StackTrace.Cycle = Циклус: {0}: {1}
8 | StackTrace.Element = у {0}.{1} ({2})
9 | StackTrace.More = ... још {0}
10 | StackTrace.Indent = \t
11 | StackTrace.Native = Системски метод
12 | StackTrace.Unknown = Непознат извор
13 |
14 | # Formatting and parsing exception messages
15 |
16 | SvetovidFormatException.Boolean = Стринг "{0}" не може са де претвори у ''boolean'' вредност
17 | SvetovidFormatException.Byte = Стринг "{0}" не може са де претвори у ''byte'' вредност
18 | SvetovidFormatException.Short = Стринг "{0}" не може са де претвори у ''short'' вредност
19 | SvetovidFormatException.Integer = Стринг "{0}" не може са де претвори у ''int'' вредност
20 | SvetovidFormatException.Long = Стринг "{0}" не може са де претвори у ''long'' вредност
21 | SvetovidFormatException.Float = Стринг "{0}" не може са де претвори у ''float'' вредност
22 | SvetovidFormatException.Double = Стринг "{0}" не може са де претвори у ''double'' вредност
23 | SvetovidFormatException.Character = Стринг "{0}" не може са де претвори у ''char'' вредност
24 | SvetovidFormatException.Array = Било је више проблема приликом претварања вредности, погледајте потиснуте изузетке
25 |
26 | SvetovidFormatException.PrintFormat.DuplicateFormatFlagsException = Грешка приликом форматирања: дуплиране заставице
27 | SvetovidFormatException.PrintFormat.UnknownFormatFlagsException = Грешка приликом форматирања: непознате заставице
28 | SvetovidFormatException.PrintFormat.IllegalFormatFlagsException = Грешка приликом форматирања: непримерене заставице
29 | SvetovidFormatException.PrintFormat.FormatFlagsConversionMismatchException = Грешка приликом форматирања: неусклађене заставице
30 | SvetovidFormatException.PrintFormat.IllegalFormatConversionException = Грешка приликом форматирања: непримерен тип конверзије
31 | SvetovidFormatException.PrintFormat.UnknownFormatConversionException = Грешка приликом форматирања: непознат тип конверзије
32 | SvetovidFormatException.PrintFormat.IllegalFormatCodePointException = Грешка приликом форматирања: непознат карактер
33 | SvetovidFormatException.PrintFormat.IllegalFormatPrecisionException = Грешка приликом форматирања: лоша прецизност
34 | SvetovidFormatException.PrintFormat.IllegalFormatWidthException = Грешка приликом форматирања: лоша ширина поља
35 | SvetovidFormatException.PrintFormat.MissingFormatArgumentException = Грешка приликом форматирања: недостаје аргумент
36 | SvetovidFormatException.PrintFormat.MissingFormatWidthException = Грешка приликом форматирања: недостаје ширина поља
37 |
38 | SvetovidFormatException.Json.Literal = {0} није валидан литерал, дозвољени литерали су null, true и false
39 | SvetovidFormatException.Json.Number = {0} није валидан број
40 | SvetovidFormatException.Json.String = {0} није валидан стринг, стрингови почињу наводником
41 | SvetovidFormatException.Json.Array = {0} није валидан низ, низови почињу угластом заградом
42 | SvetovidFormatException.Json.Object = {0} није валидан објекат, објекти почињу витичастом заградом
43 | SvetovidFormatException.Json.Value = Пронађено {0} уместо зареза
44 | SvetovidFormatException.Json.Member = Пронађено {0} уместо двотачке
45 | SvetovidFormatException.Json.Any = Пронађено {0} уместо литерала, броја, стринга, низа или објекта
46 |
47 | # JSON conversion exception messages
48 |
49 | SvetovidJsonException.Cast = Јава класа {1} не може да се претвори у JSON {0} вредност
50 | SvetovidJsonException.Path = Јава класа {1}, на путањи ''{2}'', не може да се претвори у JSON {0} вредност
51 |
52 | # IO related exception messages
53 |
54 | SvetovidIOException.BadSource = Није могуће направити читач за дати извор података: {0}
55 | SvetovidIOException.BadTarget = Није могуће направити писач за дато одердиште података: {0}
56 | SvetovidIOException.Input = Наишло се на проблем приликом читања, оригинална порука је: {0}
57 | SvetovidIOException.Output = Наишло се на проблем приликом писања, оригинална порука је: {0}
58 | SvetovidIOException.Generic = Наишло се на проблем приликом читања или писања, оригинална порука је: {0}
59 |
--------------------------------------------------------------------------------
/ressrc/i18n/exception_sr_LATIN.properties:
--------------------------------------------------------------------------------
1 | # Stack trace messages and fragments
2 |
3 | StackTrace.Thread = Izuzetak u niti "{0}"
4 | StackTrace.Main = {0}: {1}
5 | StackTrace.Cause = Uzrok: {0}: {1}
6 | StackTrace.Supressed = Potisnut: {0}: {1}
7 | StackTrace.Cycle = Ciklus: {0}: {1}
8 | StackTrace.Element = u {0}.{1} ({2})
9 | StackTrace.More = ... još {0}
10 | StackTrace.Indent = \t
11 | StackTrace.Native = Sistemski metod
12 | StackTrace.Unknown = Nepoznat izvor
13 |
14 | # Formatting and parsing exception messages
15 |
16 | SvetovidFormatException.Boolean = String "{0}" ne može da se pretvori u ''boolean'' vrednost
17 | SvetovidFormatException.Byte = String "{0}" ne može da se pretvori u ''byte'' vrednost
18 | SvetovidFormatException.Short = String "{0}" ne može da se pretvori u ''short'' vrednost
19 | SvetovidFormatException.Integer = String "{0}" ne može da se pretvori u ''int'' vrednost
20 | SvetovidFormatException.Long = String "{0}" ne može da se pretvori u ''long'' vrednost
21 | SvetovidFormatException.Float = String "{0}" ne može da se pretvori u ''float'' vrednost
22 | SvetovidFormatException.Double = String "{0}" ne može da se pretvori u ''double'' vrednost
23 | SvetovidFormatException.Character = String "{0}" ne može da se pretvori u ''char'' vrednost
24 | SvetovidFormatException.Array = Bilo je više problema prilikom pretvaranja vrednosti, pogledajte potisnute izuzetke
25 |
26 | SvetovidFormatException.PrintFormat.DuplicateFormatFlagsException = Greška prilikom formatiranja: duplirane zastavice
27 | SvetovidFormatException.PrintFormat.UnknownFormatFlagsException = Greška prilikom formatiranja: nepoznate zastavice
28 | SvetovidFormatException.PrintFormat.IllegalFormatFlagsException = Greška prilikom formatiranja: neprimerene zastavice
29 | SvetovidFormatException.PrintFormat.FormatFlagsConversionMismatchException = Greška prilikom formatiranja: neusklađene zastavice
30 | SvetovidFormatException.PrintFormat.IllegalFormatConversionException = Greška prilikom formatiranja: neprimeren tip konverzije
31 | SvetovidFormatException.PrintFormat.UnknownFormatConversionException = Greška prilikom formatiranja: nepoznat tip konverzije
32 | SvetovidFormatException.PrintFormat.IllegalFormatCodePointException = Greška prilikom formatiranja: nepoznat karakter
33 | SvetovidFormatException.PrintFormat.IllegalFormatPrecisionException = Greška prilikom formatiranja: loša preciznost
34 | SvetovidFormatException.PrintFormat.IllegalFormatWidthException = Greška prilikom formatiranja: loša širina polja
35 | SvetovidFormatException.PrintFormat.MissingFormatArgumentException = Greška prilikom formatiranja: nedostaje argument
36 | SvetovidFormatException.PrintFormat.MissingFormatWidthException = Greška prilikom formatiranja: nedostaje širina polja
37 |
38 | SvetovidFormatException.Json.Literal = {0} nije validan literal, dozvoljeni literali su null, true i false
39 | SvetovidFormatException.Json.Number = {0} nije validan broj
40 | SvetovidFormatException.Json.String = {0} nije validan string, stringovi počinju navodnikom
41 | SvetovidFormatException.Json.Array = {0} nije validan niz, nizovi počinju uglastom zagradom
42 | SvetovidFormatException.Json.Object = {0} nije validan objekat, objekti počinju vitičastom zagradom
43 | SvetovidFormatException.Json.Value = Pronađeno {0} umesto zareza
44 | SvetovidFormatException.Json.Member = Pronađeno {0} umesto dvotačke
45 | SvetovidFormatException.Json.Any = Pronađeno {0} umesto literala, broja, stringa, niza ili objekta
46 |
47 | # JSON conversion exception messages
48 |
49 | SvetovidJsonException.Cast = Java klasa {1} ne može da se pretvori u JSON {0} vrednost
50 | SvetovidJsonException.Path = Java klasa {1}, na putanji ''{2}'', ne može da se pretvori u JSON {0} vrednost
51 |
52 | # IO related exception messages
53 |
54 | SvetovidIOException.BadSource = Nije moguće napraviti čitač za dati izvor podataka: {0}
55 | SvetovidIOException.BadTarget = Nije moguće napraviti pisač za dato odredište podataka: {0}
56 | SvetovidIOException.Input = Naišlo se na problem prilikom čitanja, originalna poruka je: {0}
57 | SvetovidIOException.Output = Naišlo se na problem prilikom pisanja, originalna poruka je: {0}
58 | SvetovidIOException.Generic = Naišlo se na problem prilikom čitanja ili pisanja, originalna poruka je: {0}
59 |
--------------------------------------------------------------------------------
/res/i18n/exception.properties:
--------------------------------------------------------------------------------
1 | # Stack trace messages and fragments
2 |
3 | StackTrace.Thread = Exception in thread "{0}"
4 | StackTrace.Main = {0}: {1}
5 | StackTrace.Cause = Caused by: {0}: {1}
6 | StackTrace.Supressed = Suppressed: {0}: {1}
7 | StackTrace.Cycle = Cycle: {0}: {1}
8 | StackTrace.Element = at {0}.{1} ({2})
9 | StackTrace.More = ... {0} more
10 | StackTrace.Indent = \t
11 | StackTrace.Native = Native Method
12 | StackTrace.Unknown = Unknown Source
13 |
14 | # Formatting and parsing exception messages
15 |
16 | SvetovidFormatException.Boolean = The string {0} cannot be converted to a boolean value
17 | SvetovidFormatException.Byte = The string {0} cannot be converted to a byte value
18 | SvetovidFormatException.Short = The string {0} cannot be converted to a short integer value
19 | SvetovidFormatException.Integer = The string {0} cannot be converted to an integer value
20 | SvetovidFormatException.Long = The string {0} cannot be converted to a long integer value
21 | SvetovidFormatException.Float = The string {0} cannot be converted to a floating-point value
22 | SvetovidFormatException.Double = The string {0} cannot be converted to a double-precision floating-point value
23 | SvetovidFormatException.Character = The string {0} cannot be converted to a character value
24 | SvetovidFormatException.Array = Multiple conversion problems were encountered, see suppressed exceptions
25 |
26 | SvetovidFormatException.PrintFormat.DuplicateFormatFlagsException = Formatting problems were encountered: duplicate format flags
27 | SvetovidFormatException.PrintFormat.UnknownFormatFlagsException = Formatting problems were encountered: unknown format flags
28 | SvetovidFormatException.PrintFormat.IllegalFormatFlagsException = Formatting problems were encountered: illegal format flags
29 | SvetovidFormatException.PrintFormat.FormatFlagsConversionMismatchException = Formatting problems were encountered: format flags conversion mismatch
30 | SvetovidFormatException.PrintFormat.IllegalFormatConversionException = Formatting problems were encountered: illegal format conversion
31 | SvetovidFormatException.PrintFormat.UnknownFormatConversionException = Formatting problems were encountered: unknown format conversion
32 | SvetovidFormatException.PrintFormat.IllegalFormatCodePointException = Formatting problems were encountered: illegal format code point
33 | SvetovidFormatException.PrintFormat.IllegalFormatPrecisionException = Formatting problems were encountered: illegal format precision
34 | SvetovidFormatException.PrintFormat.IllegalFormatWidthException = Formatting problems were encountered: illegal format width
35 | SvetovidFormatException.PrintFormat.MissingFormatArgumentException = Formatting problems were encountered: missing format argument
36 | SvetovidFormatException.PrintFormat.MissingFormatWidthException = Formatting problems were encountered: missing format width
37 |
38 | SvetovidFormatException.Json.Literal = The string {0} is not a valid literal
39 | SvetovidFormatException.Json.Number = The string {0} is not a valid number
40 | SvetovidFormatException.Json.String = {0} is not a valid string value
41 | SvetovidFormatException.Json.Array = Array expected but {0} found
42 | SvetovidFormatException.Json.Object = Object expected but {0} found
43 | SvetovidFormatException.Json.Value = Separator (,) expected but {0} found
44 | SvetovidFormatException.Json.Member = Separator (:) expected but {0} found
45 | SvetovidFormatException.Json.Any = Literal, number, string, array or object expected but {0} found
46 |
47 | # JSON conversion exception messages
48 |
49 | SvetovidJsonException.Cast = Java class {1} cannot be converted to JSON {0} value
50 | SvetovidJsonException.Path = Java class {1}, on path ''{2}'', cannot be converted to JSON {0} value
51 |
52 | # IO related exception messages
53 |
54 | SvetovidIOException.BadSource = Cannot create a reader for the specified source: {0}
55 | SvetovidIOException.BadTarget = Cannot create a writer for the specified target: {0}
56 | SvetovidIOException.Input = A problem was encountered during an input operation, original message: {0}
57 | SvetovidIOException.Output = A problem was encountered during an output operation, original message: {0}
58 | SvetovidIOException.Generic = A problem was encountered during an I/O operation, original message: {0}
59 |
--------------------------------------------------------------------------------
/ressrc/i18n/exception.properties:
--------------------------------------------------------------------------------
1 | # Stack trace messages and fragments
2 |
3 | StackTrace.Thread = Exception in thread "{0}"
4 | StackTrace.Main = {0}: {1}
5 | StackTrace.Cause = Caused by: {0}: {1}
6 | StackTrace.Supressed = Suppressed: {0}: {1}
7 | StackTrace.Cycle = Cycle: {0}: {1}
8 | StackTrace.Element = at {0}.{1} ({2})
9 | StackTrace.More = ... {0} more
10 | StackTrace.Indent = \t
11 | StackTrace.Native = Native Method
12 | StackTrace.Unknown = Unknown Source
13 |
14 | # Formatting and parsing exception messages
15 |
16 | SvetovidFormatException.Boolean = The string {0} cannot be converted to a boolean value
17 | SvetovidFormatException.Byte = The string {0} cannot be converted to a byte value
18 | SvetovidFormatException.Short = The string {0} cannot be converted to a short integer value
19 | SvetovidFormatException.Integer = The string {0} cannot be converted to an integer value
20 | SvetovidFormatException.Long = The string {0} cannot be converted to a long integer value
21 | SvetovidFormatException.Float = The string {0} cannot be converted to a floating-point value
22 | SvetovidFormatException.Double = The string {0} cannot be converted to a double-precision floating-point value
23 | SvetovidFormatException.Character = The string {0} cannot be converted to a character value
24 | SvetovidFormatException.Array = Multiple conversion problems were encountered, see suppressed exceptions
25 |
26 | SvetovidFormatException.PrintFormat.DuplicateFormatFlagsException = Formatting problems were encountered: duplicate format flags
27 | SvetovidFormatException.PrintFormat.UnknownFormatFlagsException = Formatting problems were encountered: unknown format flags
28 | SvetovidFormatException.PrintFormat.IllegalFormatFlagsException = Formatting problems were encountered: illegal format flags
29 | SvetovidFormatException.PrintFormat.FormatFlagsConversionMismatchException = Formatting problems were encountered: format flags conversion mismatch
30 | SvetovidFormatException.PrintFormat.IllegalFormatConversionException = Formatting problems were encountered: illegal format conversion
31 | SvetovidFormatException.PrintFormat.UnknownFormatConversionException = Formatting problems were encountered: unknown format conversion
32 | SvetovidFormatException.PrintFormat.IllegalFormatCodePointException = Formatting problems were encountered: illegal format code point
33 | SvetovidFormatException.PrintFormat.IllegalFormatPrecisionException = Formatting problems were encountered: illegal format precision
34 | SvetovidFormatException.PrintFormat.IllegalFormatWidthException = Formatting problems were encountered: illegal format width
35 | SvetovidFormatException.PrintFormat.MissingFormatArgumentException = Formatting problems were encountered: missing format argument
36 | SvetovidFormatException.PrintFormat.MissingFormatWidthException = Formatting problems were encountered: missing format width
37 |
38 | SvetovidFormatException.Json.Literal = The string {0} is not a valid literal
39 | SvetovidFormatException.Json.Number = The string {0} is not a valid number
40 | SvetovidFormatException.Json.String = {0} is not a valid string value
41 | SvetovidFormatException.Json.Array = Array expected but {0} found
42 | SvetovidFormatException.Json.Object = Object expected but {0} found
43 | SvetovidFormatException.Json.Value = Separator (,) expected but {0} found
44 | SvetovidFormatException.Json.Member = Separator (:) expected but {0} found
45 | SvetovidFormatException.Json.Any = Literal, number, string, array or object expected but {0} found
46 |
47 | # JSON conversion exception messages
48 |
49 | SvetovidJsonException.Cast = Java class {1} cannot be converted to JSON {0} value
50 | SvetovidJsonException.Path = Java class {1}, on path ''{2}'', cannot be converted to JSON {0} value
51 |
52 | # IO related exception messages
53 |
54 | SvetovidIOException.BadSource = Cannot create a reader for the specified source: {0}
55 | SvetovidIOException.BadTarget = Cannot create a writer for the specified target: {0}
56 | SvetovidIOException.Input = A problem was encountered during an input operation, original message: {0}
57 | SvetovidIOException.Output = A problem was encountered during an output operation, original message: {0}
58 | SvetovidIOException.Generic = A problem was encountered during an I/O operation, original message: {0}
59 |
--------------------------------------------------------------------------------
/src/org/svetovid/util/OperatingSystem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.util;
18 |
19 | public enum OperatingSystem {
20 |
21 | WINDOWS_3_1 (OperatingSystemFamily.WINDOWS, "Windows 3.1"),
22 | WINDOWS_NT_3_51 (OperatingSystemFamily.WINDOWS, "Windows 3.5"),
23 | WINDOWS_NT_4_0 (OperatingSystemFamily.WINDOWS, "Windows NT 4.0"),
24 | WINDOWS_95 (OperatingSystemFamily.WINDOWS, "Windows 95"),
25 | WINDOWS_98 (OperatingSystemFamily.WINDOWS, "Windows 98"),
26 | WINDOWS_ME (OperatingSystemFamily.WINDOWS, "Windows Me"),
27 | WINDOWS_9X (OperatingSystemFamily.WINDOWS, "Windows 9X (unknown)"),
28 | WINDOWS_NT (OperatingSystemFamily.WINDOWS, "Windows NT", "Windows NT (unknown)"),
29 | WINDOWS_2000 (OperatingSystemFamily.WINDOWS, "Windows 2000"),
30 | WINDOWS_XP (OperatingSystemFamily.WINDOWS, "Windows XP"),
31 | WINDOWS_2003 (OperatingSystemFamily.WINDOWS, "Windows 2003"),
32 | WINDOWS_VISTA (OperatingSystemFamily.WINDOWS, "Windows Vista"),
33 | WINDOWS_7 (OperatingSystemFamily.WINDOWS, "Windows 7"),
34 | WINDOWS_2008 (OperatingSystemFamily.WINDOWS, "Windows Server 2008", "Windows Server 2008 R2"),
35 | WINDOWS_8 (OperatingSystemFamily.WINDOWS, "Windows 8", "Windows 8.1"),
36 | WINDOWS_2012 (OperatingSystemFamily.WINDOWS, "Windows Server 2012", "Windows Server 2012 R2"),
37 | WINDOWS_10 (OperatingSystemFamily.WINDOWS, "Windows 10"),
38 | WINDOWS (OperatingSystemFamily.WINDOWS, "Windows", "Windows (unknown)"),
39 | MAC_OS_X (OperatingSystemFamily.MAC, "Mac OS X"),
40 | MAC (OperatingSystemFamily.MAC, "Mac OS"),
41 | SUN_OS (OperatingSystemFamily.UNIX, "SunOS"),
42 | SOLARIS (OperatingSystemFamily.UNIX, "Solaris"),
43 | LINUX (OperatingSystemFamily.UNIX, "Linux"),
44 | FREE_BSD (OperatingSystemFamily.UNIX, "FreeBSD"),
45 | HP_UX (OperatingSystemFamily.UNIX, "HP-UX"),
46 | HP_MPE_IX (OperatingSystemFamily.UNIX, "MPE/iX"),
47 | HP_TRU64_UNIX (OperatingSystemFamily.UNIX, "Digital UNIX", "Tru64 Uni"),
48 | IBM_AIX (OperatingSystemFamily.UNIX, "AIX"),
49 | IBM_OS390 (OperatingSystemFamily.UNIX, "OS/390"),
50 | OSF1 (OperatingSystemFamily.UNIX, "OSF1", "OSF/1"),
51 | SGI_IRIX (OperatingSystemFamily.UNIX, "Irix"),
52 | UNIX (OperatingSystemFamily.UNIX, "Unix"),
53 | NETWARE_4_11 (OperatingSystemFamily.OTHER, "NetWare 4.11"),
54 | NETWARE (OperatingSystemFamily.OTHER, "NetWare"),
55 | HP_OPEN_VMS (OperatingSystemFamily.OTHER, "OpenVMS"),
56 | IBM_OS2 (OperatingSystemFamily.OTHER, "OS/2"),
57 | UNKNOWN (OperatingSystemFamily.OTHER, "Unknown");
58 |
59 | public static final OperatingSystem CURRENT = forName(System.getProperty("os.name"));
60 |
61 | private final OperatingSystemFamily family;
62 | private final String names[];
63 |
64 | private OperatingSystem(OperatingSystemFamily family, String... names){
65 | this.family = family;
66 | this.names = names;
67 | }
68 |
69 | public String getName() {
70 | return names[0];
71 | }
72 |
73 | public OperatingSystemFamily getFamily() {
74 | return family;
75 | }
76 |
77 | public static OperatingSystem forName(String name){
78 | name = name.toLowerCase();
79 | for (OperatingSystem os : values()) {
80 | for (String n : os.names) {
81 | if (name.contains(n.toLowerCase()))
82 | return os;
83 | }
84 | }
85 | return UNKNOWN;
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/org/svetovid/SvetovidFormatException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid;
18 |
19 | import java.util.IllegalFormatException;
20 | import java.util.List;
21 |
22 | /**
23 | * Signals that a parsing error of some sort has occurred.
24 | *
25 | * @author Ivan Pribela
26 | *
27 | * @see org.svetovid.io.SvetovidReader
28 | * @see org.svetovid.io.SvetovidWriter
29 | */
30 | public class SvetovidFormatException extends SvetovidException {
31 |
32 | private static final long serialVersionUID = 1829394491209593218L;
33 |
34 | /**
35 | * Constructs a {@code SvetovidFormatException} with the specified message.
36 | *
37 | * @param type
38 | * The type to which the string could not be parsed
39 | * @param string
40 | * The string that could not be parsed
41 | */
42 | public SvetovidFormatException(Class> type, String string) {
43 | super(type.getSimpleName(),
44 | string == null ? null : "\"" + string + "\"");
45 | }
46 |
47 | /**
48 | * Constructs a {@code SvetovidFormatException} with the specified detail
49 | * message and cause.
50 | *
51 | * @param type
52 | * The type to which the string could not be parsed
53 | * @param string
54 | * The string that could not be parsed
55 | * @param cause
56 | * The cause, if any
57 | */
58 | public SvetovidFormatException(Class> type, String string,
59 | Throwable cause) {
60 | super(type.getSimpleName(), cause,
61 | string == null ? null : "\"" + string + "\"");
62 | }
63 |
64 | /**
65 | * Constructs a {@code SvetovidFormatException} with multiple suppressed
66 | * causes.
67 | *
68 | * @param causes
69 | * The suppressed causes of this exception
70 | */
71 | public SvetovidFormatException(Throwable... causes) {
72 | super("Array");
73 | for (Throwable cause : causes) {
74 | addSuppressed(cause);
75 | }
76 | }
77 |
78 | /**
79 | * Constructs a {@code SvetovidFormatException} with multiple suppressed
80 | * causes.
81 | *
82 | * @param causes
83 | * The suppressed causes of this exception
84 | */
85 | public SvetovidFormatException(List extends Throwable> causes) {
86 | super("Array");
87 | for (Throwable cause : causes) {
88 | addSuppressed(cause);
89 | }
90 | }
91 |
92 | /**
93 | * Constructs a {@code SvetovidFormatException} with the specified detail
94 | * message and cause.
95 | *
96 | * @param messageKey
97 | * The resource bundle key of the detail message, which is saved
98 | * for later retrieval by the {@link #getMessage()} method
99 | * @param string
100 | * The string that could not be parsed
101 | * @param cause
102 | * The cause, if any
103 | */
104 | public SvetovidFormatException(String messageKey, String string,
105 | Throwable cause) {
106 | super(messageKey, cause, string);
107 | }
108 |
109 | /**
110 | * Constructs a {@code SvetovidFormatException} with the specified detail
111 | * message and cause.
112 | *
113 | * @param string
114 | * The string that could not be parsed
115 | * @param cause
116 | * The cause of the format exception
117 | */
118 | public SvetovidFormatException(IllegalFormatException cause, String string) {
119 | super("PrintFormat." + cause.getClass().getSimpleName(), cause, string);
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/res/i18n/exception_sr_LATIN.properties:
--------------------------------------------------------------------------------
1 | # Stack trace messages and fragments
2 |
3 | StackTrace.Thread = Izuzetak u niti "{0}"
4 | StackTrace.Main = {0}: {1}
5 | StackTrace.Cause = Uzrok: {0}: {1}
6 | StackTrace.Supressed = Potisnut: {0}: {1}
7 | StackTrace.Cycle = Ciklus: {0}: {1}
8 | StackTrace.Element = u {0}.{1} ({2})
9 | StackTrace.More = ... jo\u0161 {0}
10 | StackTrace.Indent = \t
11 | StackTrace.Native = Sistemski metod
12 | StackTrace.Unknown = Nepoznat izvor
13 |
14 | # Formatting and parsing exception messages
15 |
16 | SvetovidFormatException.Boolean = String "{0}" ne mo\u017ee da se pretvori u ''boolean'' vrednost
17 | SvetovidFormatException.Byte = String "{0}" ne mo\u017ee da se pretvori u ''byte'' vrednost
18 | SvetovidFormatException.Short = String "{0}" ne mo\u017ee da se pretvori u ''short'' vrednost
19 | SvetovidFormatException.Integer = String "{0}" ne mo\u017ee da se pretvori u ''int'' vrednost
20 | SvetovidFormatException.Long = String "{0}" ne mo\u017ee da se pretvori u ''long'' vrednost
21 | SvetovidFormatException.Float = String "{0}" ne mo\u017ee da se pretvori u ''float'' vrednost
22 | SvetovidFormatException.Double = String "{0}" ne mo\u017ee da se pretvori u ''double'' vrednost
23 | SvetovidFormatException.Character = String "{0}" ne mo\u017ee da se pretvori u ''char'' vrednost
24 | SvetovidFormatException.Array = Bilo je vi\u0161e problema prilikom pretvaranja vrednosti, pogledajte potisnute izuzetke
25 |
26 | SvetovidFormatException.PrintFormat.DuplicateFormatFlagsException = Gre\u0161ka prilikom formatiranja: duplirane zastavice
27 | SvetovidFormatException.PrintFormat.UnknownFormatFlagsException = Gre\u0161ka prilikom formatiranja: nepoznate zastavice
28 | SvetovidFormatException.PrintFormat.IllegalFormatFlagsException = Gre\u0161ka prilikom formatiranja: neprimerene zastavice
29 | SvetovidFormatException.PrintFormat.FormatFlagsConversionMismatchException = Gre\u0161ka prilikom formatiranja: neuskla\u0111ene zastavice
30 | SvetovidFormatException.PrintFormat.IllegalFormatConversionException = Gre\u0161ka prilikom formatiranja: neprimeren tip konverzije
31 | SvetovidFormatException.PrintFormat.UnknownFormatConversionException = Gre\u0161ka prilikom formatiranja: nepoznat tip konverzije
32 | SvetovidFormatException.PrintFormat.IllegalFormatCodePointException = Gre\u0161ka prilikom formatiranja: nepoznat karakter
33 | SvetovidFormatException.PrintFormat.IllegalFormatPrecisionException = Gre\u0161ka prilikom formatiranja: lo\u0161a preciznost
34 | SvetovidFormatException.PrintFormat.IllegalFormatWidthException = Gre\u0161ka prilikom formatiranja: lo\u0161a \u0161irina polja
35 | SvetovidFormatException.PrintFormat.MissingFormatArgumentException = Gre\u0161ka prilikom formatiranja: nedostaje argument
36 | SvetovidFormatException.PrintFormat.MissingFormatWidthException = Gre\u0161ka prilikom formatiranja: nedostaje \u0161irina polja
37 |
38 | SvetovidFormatException.Json.Literal = {0} nije validan literal, dozvoljeni literali su null, true i false
39 | SvetovidFormatException.Json.Number = {0} nije validan broj
40 | SvetovidFormatException.Json.String = {0} nije validan string, stringovi po\u010dinju navodnikom
41 | SvetovidFormatException.Json.Array = {0} nije validan niz, nizovi po\u010dinju uglastom zagradom
42 | SvetovidFormatException.Json.Object = {0} nije validan objekat, objekti po\u010dinju viti\u010dastom zagradom
43 | SvetovidFormatException.Json.Value = Prona\u0111eno {0} umesto zareza
44 | SvetovidFormatException.Json.Member = Prona\u0111eno {0} umesto dvota\u010dke
45 | SvetovidFormatException.Json.Any = Prona\u0111eno {0} umesto literala, broja, stringa, niza ili objekta
46 |
47 | # JSON conversion exception messages
48 |
49 | SvetovidJsonException.Cast = Java klasa {1} ne mo\u017ee da se pretvori u JSON {0} vrednost
50 | SvetovidJsonException.Path = Java klasa {1}, na putanji ''{2}'', ne mo\u017ee da se pretvori u JSON {0} vrednost
51 |
52 | # IO related exception messages
53 |
54 | SvetovidIOException.BadSource = Nije mogu\u0107e napraviti \u010dita\u010d za dati izvor podataka: {0}
55 | SvetovidIOException.BadTarget = Nije mogu\u0107e napraviti pisa\u010d za dato odredi\u0161te podataka: {0}
56 | SvetovidIOException.Input = Nai\u0161lo se na problem prilikom \u010ditanja, originalna poruka je: {0}
57 | SvetovidIOException.Output = Nai\u0161lo se na problem prilikom pisanja, originalna poruka je: {0}
58 | SvetovidIOException.Generic = Nai\u0161lo se na problem prilikom \u010ditanja ili pisanja, originalna poruka je: {0}
59 |
--------------------------------------------------------------------------------
/src/org/svetovid/dialogs/AutoCloseDialogFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Ivan Pribela
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.svetovid.dialogs;
18 |
19 | import java.awt.Component;
20 | import java.awt.datatransfer.Clipboard;
21 | import java.util.Locale;
22 |
23 | import javax.swing.Icon;
24 |
25 | public class AutoCloseDialogFactory extends DefaultDialogFactory {
26 |
27 | public AutoCloseDialogFactory() {
28 | super();
29 | }
30 |
31 | public AutoCloseDialogFactory(Locale locale) {
32 | super(locale);
33 | }
34 |
35 | public AutoCloseDialogFactory(Clipboard clipboard) {
36 | super(clipboard);
37 | }
38 |
39 | public AutoCloseDialogFactory(Locale locale, Clipboard clipboard) {
40 | super(locale, clipboard);
41 | }
42 |
43 | public int getDefaultAutoCloseTimeout() {
44 | return defaultAutoCloseTimeout;
45 | }
46 |
47 | public void setDefaultAutoCloseTimeout(int defaultAutoCloseTimeout) {
48 | this.defaultAutoCloseTimeout = defaultAutoCloseTimeout;
49 | }
50 |
51 | @Override
52 | public void showMessage(Component component, String text, int timeout) {
53 | super.showMessage(component, text, timeout);
54 | }
55 |
56 | @Override
57 | public void showInformation(Component component, String text, int timeout) {
58 | super.showInformation(component, text, timeout);
59 | }
60 |
61 | @Override
62 | public void showWarning(Component component, String text, int timeout) {
63 | super.showWarning(component, text, timeout);
64 | }
65 |
66 | @Override
67 | public void showError(Component component, String text, int timeout) {
68 | super.showError(component, text, timeout);
69 | }
70 |
71 | @Override
72 | public void showError(Component component, String text, Throwable th, int timeout) {
73 | super.showError(component, text, th, timeout);
74 | }
75 |
76 | @Override
77 | public void showException(Component component, Throwable th, int timeout) {
78 | super.showException(component, th, timeout);
79 | }
80 |
81 | @Override
82 | public boolean askConfirmation(Component component, String text, int timeout) {
83 | return super.askConfirmation(component, text, timeout);
84 | }
85 |
86 | @Override
87 | public Boolean askConfirmationWithCancel(Component component, String text, int timeout) {
88 | return super.askConfirmationWithCancel(component, text, timeout);
89 | }
90 |
91 | @Override
92 | public String askQuestion(Component component, String text, int timeout) {
93 | return super.askQuestion(component, text, timeout);
94 | }
95 |
96 | @Override
97 | public String askQuestion(Component component, String text, String answer, int timeout) {
98 | return super.askQuestion(component, text, answer, timeout);
99 | }
100 |
101 | @Override
102 | public Object askQuestion(Component component, String text, Object[] options, Object defaultOption, int timeout) {
103 | return super.askQuestion(component, text, options, defaultOption, timeout);
104 | }
105 |
106 | @Override
107 | public char[] askPassword(Component component, String text, int timeout) {
108 | return super.askPassword(component, text, timeout);
109 | }
110 |
111 | @Override
112 | public LoginData askLogin(Component component, String text, int timeout) {
113 | return super.askLogin(component, text, timeout);
114 | }
115 |
116 | @Override
117 | public LoginData askLogin(Component component, String text, String username, int timeout) {
118 | return super.askLogin(component, text, username, timeout);
119 | }
120 |
121 | @Override
122 | public boolean showDialog(Component component, Component content, String title, Icon icon, int timeout) {
123 | return super.showDialog(component, content, title, icon, timeout);
124 | }
125 |
126 | @Override
127 | public T showDialog(Component component, DialogContent content, String title, Icon icon, int timeout) {
128 | return super.showDialog(component, content, title, icon, timeout);
129 | }
130 | }
131 |
--------------------------------------------------------------------------------