Browse Source

FIFO-Pipe implementiert mit Platzhalter Klasse fuer Messages

main
eichehome 8 months ago
parent
commit
0ffffe257e
  1. 5
      nbproject/project.properties
  2. 17
      src/client/MainClient.java
  3. 17
      src/client/MainClient1.java
  4. 32
      src/server/Element.java
  5. 52
      src/server/FifoPipe.java
  6. 38
      src/server/PipeElement.java
  7. 61
      src/server/PipeTest.java

5
nbproject/project.properties

@ -1,9 +1,10 @@ @@ -1,9 +1,10 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=ChatApplication
application.vendor=eichehome
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
@ -32,6 +33,7 @@ dist.jar=${dist.dir}/ChatApplication.jar @@ -32,6 +33,7 @@ dist.jar=${dist.dir}/ChatApplication.jar
dist.javadoc.dir=${dist.dir}/javadoc
dist.jlink.dir=${dist.dir}/jlink
dist.jlink.output=${dist.jlink.dir}/ChatApplication
endorsed.classpath=
excludes=
includes=**
jar.compress=false
@ -76,6 +78,7 @@ manifest.file=manifest.mf @@ -76,6 +78,7 @@ manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
project.license=gpl30
run.classpath=\
${javac.classpath}:\
${build.classes.dir}

17
src/client/MainClient.java

@ -1,7 +1,18 @@ @@ -1,7 +1,18 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* Copyright (C) 2021 eichehome
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package client;

17
src/client/MainClient1.java

@ -1,7 +1,18 @@ @@ -1,7 +1,18 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* Copyright (C) 2021 eichehome
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package client;

32
src/server/Element.java

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
/*
* Copyright (C) 2021 eichehome
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server;
/**
*
* @author eichehome
*/
public class Element {
private String bezeichner;
public Element(String inhalt) {
bezeichner = inhalt;
}
public String gebeData() {
return bezeichner;
}
}

52
src/server/FifoPipe.java

@ -1,7 +1,18 @@ @@ -1,7 +1,18 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* Copyright (C) 2021 eichehome
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server;
@ -11,15 +22,42 @@ package server; @@ -11,15 +22,42 @@ package server;
*/
public class FifoPipe {
private PipeElement firstElement;
private PipeElement lastElement;
public PipeElement firstElement;
public PipeElement lastElement;
public FifoPipe() {
}
public queuElement(Object element) {
public void queuElement(Element element) {
PipeElement pipeElement = new PipeElement(element);
try {
lastElement.setNextElement(pipeElement);
lastElement = pipeElement;
} catch (NullPointerException ex) {
firstElement = pipeElement;
lastElement = pipeElement;
}
}
public PipeElement getNextElement() {
PipeElement result = null;
if (firstElement == null) {
return result;
} else {
if (firstElement == lastElement) {
result = firstElement;
firstElement = null;
lastElement = null;
return result;
} else {
result = firstElement;
PipeElement next = firstElement.getNext();
firstElement = next;
return result;
}
}
}
}

38
src/server/PipeElement.java

@ -1,7 +1,18 @@ @@ -1,7 +1,18 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* Copyright (C) 2021 eichehome
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server;
@ -11,9 +22,24 @@ package server; @@ -11,9 +22,24 @@ package server;
*/
public class PipeElement {
private PipeElement naechster;
private Object data;
private PipeElement next;
private Element data;
public PipeElement(Element el) {
data = el;
next = null;
}
public PipeElement getNext() {
return next;
}
public void setNextElement(PipeElement element) {
next = element;
}
public void setNextElement(Obj)
public Element getData() {
return data;
}
}

61
src/server/PipeTest.java

@ -0,0 +1,61 @@ @@ -0,0 +1,61 @@
/*
* Copyright (C) 2021 eichehome
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server;
/**
*
* @author eichehome
*/
public class PipeTest {
public static void main(String[] args) {
FifoPipe pipe = new FifoPipe();
System.out.println("Erstes Element: " + pipe.firstElement);
System.out.println("Letztes Element: " + pipe.lastElement);
Element el = new Element("Test");
pipe.queuElement(el);
System.out.println("Angehängt");
System.out.println("Erstes Element: " + pipe.firstElement);
System.out.println("Letztes Element: " + pipe.lastElement);
System.out.println("Erstes Element Inhalt: " + pipe.firstElement.getData().gebeData());
System.out.println("Letztes Element Inhalt: " + pipe.lastElement.getData().gebeData());
Element el2 = new Element("Test2");
pipe.queuElement(el2);
System.out.println("Angehängt2");
System.out.println("Erstes Element: " + pipe.firstElement);
System.out.println("Letztes Element: " + pipe.lastElement);
System.out.println("Erstes Element Inhalt: " + pipe.firstElement.getData().gebeData());
System.out.println("Letztes Element Inhalt: " + pipe.lastElement.getData().gebeData());
PipeElement pipeElement = pipe.getNextElement();
System.out.println("Oben entnommen");
System.out.println("Entnommen Inhalt: " + pipeElement.getData().gebeData());
System.out.println("Erstes Element: " + pipe.firstElement);
System.out.println("Letztes Element: " + pipe.lastElement);
System.out.println("Erstes Element Inhalt: " + pipe.firstElement.getData().gebeData());
System.out.println("Letztes Element Inhalt: " + pipe.lastElement.getData().gebeData());
PipeElement pipeElement2 = pipe.getNextElement();
System.out.println("Oben entnommen2");
System.out.println("Entnommen Inhalt: " + pipeElement2.getData().gebeData());
System.out.println("Erstes Element: " + pipe.firstElement);
System.out.println("Letztes Element: " + pipe.lastElement);
//Wieso wills nicht funktionieren?
PipeElement pipeElement3 = pipe.getNextElement();
System.out.println("Oben entnommen3");
//System.out.println(pipeElement3.getData().gebeData());
System.out.println("Erstes Element: " + pipe.firstElement);
System.out.println("Letztes Element: " + pipe.lastElement);
}
}
Loading…
Cancel
Save