Skip to content

Commit

Permalink
BUG FIX
Browse files Browse the repository at this point in the history
  • Loading branch information
ChriZ982 committed May 29, 2015
1 parent 5bbc1f4 commit 41ad61b
Show file tree
Hide file tree
Showing 20 changed files with 357 additions and 217 deletions.
Binary file modified Facharbeit.jar
Binary file not shown.
62 changes: 40 additions & 22 deletions src/com/facharbeit/io/FileHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ public FileHandler(File file)
/**
* Erstellt eine neue Datei.
*
* @throws java.lang.Exception Fehler
*
* @throws java.io.IOException
*/
public void create() throws Exception
public void create() throws IOException
{
file.getParentFile().mkdirs();
if(file.createNewFile())
Expand All @@ -49,9 +50,9 @@ public void create() throws Exception
/**
* Löscht eine bestehende Datei.
*
* @throws java.lang.Exception Fehler
*
*/
public void delete() throws Exception
public void delete()
{
if(file.delete())
Logger.log("\"" + file.getName() + "\" wurde gelöscht.", 0);
Expand All @@ -62,9 +63,9 @@ public void delete() throws Exception
*
* @return Existiert die Datei?
*
* @throws java.lang.Exception Fehler
*
*/
public boolean exists() throws Exception
public boolean exists()
{
return file.isFile() && file.exists();
}
Expand All @@ -74,9 +75,11 @@ public boolean exists() throws Exception
*
* @param dest Zielpfad
*
* @throws java.lang.Exception Fehler
* @throws java.io.IOException
*
*
*/
public void copy(String dest) throws Exception
public void copy(String dest) throws IOException
{
if(exists())
{
Expand All @@ -91,9 +94,11 @@ public void copy(String dest) throws Exception
*
* @param dest Zielpfad
*
* @throws java.lang.Exception Fehler
* @throws java.io.IOException
*
*
*/
public void copyFromRes(String dest) throws Exception
public void copyFromRes(String dest) throws IOException
{
File f = new File(dest + file.getName());
f.getParentFile().mkdirs();
Expand All @@ -115,9 +120,11 @@ public void copyFromRes(String dest) throws Exception
*
* @return Anzahl der Zeilen
*
* @throws java.lang.Exception Fehler
* @throws java.io.IOException
*
*
*/
public int length() throws Exception
public int length() throws IOException
{
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "ISO-8859-1"));
int lines = 0;
Expand All @@ -134,9 +141,11 @@ public int length() throws Exception
*
* @return Inhalt dieser Zeile
*
* @throws java.lang.Exception Fehler
* @throws java.io.IOException
*
*
*/
public String read(int lineNumber) throws Exception
public String read(int lineNumber) throws IOException
{
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "ISO-8859-1"));
for(int i = 0; i < lineNumber; i++)
Expand All @@ -151,9 +160,11 @@ public String read(int lineNumber) throws Exception
*
* @return Ganze Datei als String Array
*
* @throws java.lang.Exception Fehler
* @throws java.io.IOException
*
*
*/
public String[] read() throws Exception
public String[] read() throws IOException
{
int length = length();
String[] text = new String[length];
Expand All @@ -169,9 +180,11 @@ public String[] read() throws Exception
*
* @return Ganze Datei als String
*
* @throws java.lang.Exception Fehler
* @throws java.io.IOException
*
*
*/
public String asString() throws Exception
public String asString() throws IOException
{
String asString = "";
String[] text = read();
Expand All @@ -185,9 +198,12 @@ public String asString() throws Exception
*
* @param text Daten, die in die Datei geschrieben werder sollen
*
* @throws java.lang.Exception Fehler
* @throws java.io.UnsupportedEncodingException
* @throws java.io.FileNotFoundException
*
*
*/
public void write(String[] text) throws Exception
public void write(String[] text) throws UnsupportedEncodingException, FileNotFoundException
{
PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "ISO-8859-1"));
for(int i = 0; i < text.length; i++)
Expand All @@ -206,9 +222,11 @@ public void write(String[] text) throws Exception
* @param lineNumber Zeile, die neu geschrieben werden soll
* @param text Text, der geschrieben werden soll
*
* @throws java.lang.Exception Fehler
* @throws java.io.IOException
*
*
*/
public void write(int lineNumber, String text) throws Exception
public void write(int lineNumber, String text) throws IOException
{
String[] oldText = read();
String[] newText;
Expand Down
22 changes: 14 additions & 8 deletions src/com/facharbeit/io/FolderHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.facharbeit.tools.Logger;
import java.io.File;
import java.io.IOException;
import java.nio.file.*;
import java.util.Iterator;

Expand Down Expand Up @@ -40,9 +41,11 @@ public FolderHandler(File file)
*
* @param dest Zielpfad
*
* @throws java.lang.Exception Fehler
* @throws java.io.IOException
*
*
*/
public void copyContent(String dest) throws Exception
public void copyContent(String dest) throws IOException
{
Iterator it = Files.list(Paths.get(file.getPath())).iterator();
Logger.enable(false);
Expand All @@ -55,9 +58,10 @@ public void copyContent(String dest) throws Exception
/**
* Löscht den Inhalt des Ordners.
*
* @throws java.lang.Exception Fehler
*
* @throws java.io.IOException
*/
public void deleteContent() throws Exception
public void deleteContent() throws IOException
{
if(!exists())
return;
Expand All @@ -74,9 +78,9 @@ public void deleteContent() throws Exception
*
* @return Existiert er?
*
* @throws java.lang.Exception Fehler
*
*/
public boolean exists() throws Exception
public boolean exists()
{
return file.isDirectory() && file.exists();
}
Expand All @@ -86,9 +90,11 @@ public boolean exists() throws Exception
*
* @return Ist er leer?
*
* @throws java.lang.Exception Fehler
* @throws java.io.IOException
*
*
*/
public boolean isEmpty() throws Exception
public boolean isEmpty() throws IOException
{
return !exists() || !Files.list(Paths.get(file.getPath())).iterator().hasNext();
}
Expand Down
41 changes: 28 additions & 13 deletions src/com/facharbeit/io/HtmlReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.facharbeit.sql.SqlTableReader;
import com.facharbeit.tools.*;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.util.*;

/**
Expand Down Expand Up @@ -43,7 +44,11 @@ public class HtmlReader
*
* @return Ein Array mit Schulklassen in denen die jeweiligen Vertretungen gespeichert sind
*
* @throws java.lang.Exception Fehler
* @throws java.lang.reflect.InvocationTargetException
* @throws java.lang.IllegalAccessException
* @throws java.io.IOException
*
*
*/
public static SchoolClass[] today() throws Exception
{
Expand Down Expand Up @@ -72,7 +77,11 @@ public static SchoolClass[] today() throws Exception
*
* @return Ein Array mit Schulklassen in denen die jeweiligen Vertretungen gespeichert sind
*
* @throws java.lang.Exception Fehler
* @throws java.lang.IllegalAccessException
* @throws java.lang.reflect.InvocationTargetException
* @throws java.io.IOException
*
*
*/
public static SchoolClass[] tomorrow() throws Exception
{
Expand Down Expand Up @@ -105,9 +114,13 @@ public static SchoolClass[] tomorrow() throws Exception
*
* @return Ein Array mit Schulklassen in denen die jeweiligen Vertretungen gespeichert sind
*
* @throws java.lang.Exception Fehler
* @throws java.lang.reflect.InvocationTargetException
* @throws java.lang.IllegalAccessException
* @throws java.io.IOException
*
*
*/
public static SchoolClass[] forSql() throws Exception
public static SchoolClass[] forSql() throws InvocationTargetException, IllegalAccessException, IOException
{
return sort(getAllHtml(PathConverter.convert(Settings.load("pathData") + "/Source/")));
}
Expand All @@ -119,9 +132,11 @@ public static SchoolClass[] forSql() throws Exception
*
* @return Ein Array in denen alle in den Quelldateien vorhandenen Vertretungen gespeichert sind (alle Tage)
*
* @throws java.lang.Exception Fehler
* @throws java.io.IOException
*
*
*/
public static SchoolClass[] getAllHtml(String path) throws Exception
public static SchoolClass[] getAllHtml(String path) throws IOException
{
if(new FolderHandler(path).isEmpty())
return new SchoolClass[]
Expand Down Expand Up @@ -195,7 +210,7 @@ public static SchoolClass[] getAllHtml(String path) throws Exception
* @return Den genauen HTML-Tag;
* Bsp: findHtmlTag("blabla&lt;font color="black"&gt;blabla", "font") gibt "&lt;font color="black"&gt;" züruck
*/
private static String findHtmlTag(String source, String toFind) throws Exception
private static String findHtmlTag(String source, String toFind)
{
if(!source.contains("<" + toFind) || !source.contains(">"))
return ">";
Expand All @@ -211,7 +226,7 @@ private static String findHtmlTag(String source, String toFind) throws Exception
*
* @return Die Tabelle mit den Vertretungen (Anfang: "&lt;table&gt;"; Ende: "&lt;/table&gt;")
*/
private static String getTable(String source) throws Exception
private static String getTable(String source)
{
source = source.substring(source.indexOf("<TABLE border=\"3\" rules=\"all\" bgcolor=\"#E7E7E7\" cellpadding=\"1\" cellspacing=\"1\">"));
source = source.substring(0, source.indexOf(findHtmlTag(source, "/TABLE")) + findHtmlTag(source, "/TABLE").length());
Expand All @@ -226,7 +241,7 @@ private static String getTable(String source) throws Exception
*
* @return Ob der String nur aus Ziffern und "extraChars" besteht
*/
private static boolean validateAsNumber(String s, char... extraChars) throws Exception
private static boolean validateAsNumber(String s, char... extraChars)
{
boolean found = false;
if(s.isEmpty())
Expand Down Expand Up @@ -261,7 +276,7 @@ private static boolean validateAsNumber(String s, char... extraChars) throws Exc
*
* @return Die nächste Zelle der Tabelle
*/
private static String readEntry(String source) throws Exception
private static String readEntry(String source)
{
if(source.contains("<font"))
source = source.substring(source.indexOf(findHtmlTag(source, "font")) + findHtmlTag(source, "font").length());
Expand All @@ -285,9 +300,9 @@ private static String readEntry(String source) throws Exception
*
* @return Sortiertes Array
*
* @throws java.lang.Exception Fehler
*
*/
public static SchoolClass[] sort(SchoolClass[] schoolClasses) throws Exception
public static SchoolClass[] sort(SchoolClass[] schoolClasses)
{
if(schoolClasses == null)
return null;
Expand Down Expand Up @@ -326,7 +341,7 @@ public static SchoolClass[] sort(SchoolClass[] schoolClasses) throws Exception
*
* @return Liste der Dateien
*/
private static ArrayList<File> getFiles(String path) throws Exception
private static ArrayList<File> getFiles(String path) throws IOException
{
while(path.endsWith("\\"))
path = path.substring(0, path.length() - 1);
Expand Down
Loading

0 comments on commit 41ad61b

Please sign in to comment.