Skip to content

Commit

Permalink
Changed Fields from Array to ArrayList
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Downarowicz committed Mar 16, 2022
1 parent 89776ce commit 665f187
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>at.downardo</groupId>
<artifactId>j3270Server</artifactId>
<version>0.0.5</version>
<version>0.0.6</version>
<name>Java 3270 Server</name>
<packaging>jar</packaging>
<description>This libary allows the user to write servers for IBM 3270 Terminal emulators.</description>
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/at/downardo/j3270Server/Looper.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ public static Response HandleScreen(Screen screen, HashMap<String, FieldRule> ru
HashMap<String,String> origValues = new HashMap<String,String>();
HashMap<String, Field> fields = new HashMap<String,Field>();

for(int i = 0; i < screen.getFields().length; i++) {
/*for(int i = 0; i < screen.getFields().length; i++) {
if(screen.getFields()[i].getName() != "") {
origValues.put(screen.getFields()[i].getName(), screen.getFields()[i].getContent());
fields.put(screen.getFields()[i].getName(), screen.getFields()[i]);
}
}*/
for(Field fld : screen.getFields()) {
if(fld.getName() != "") {
origValues.put(fld.getName(), fld.getContent());
fields.put(fld.getName(), fld);
}
}

//Make our own field values map so we don't alter the caller's value
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/at/downardo/j3270Server/Screen.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@
*/
public class Screen {

private Field[] fields;
//private Field[] fields;
private ArrayList<Field> fields;

public Screen(Field[] _fields) {
/*public Screen(Field[] _fields) {
this.fields = _fields;
}*/
public Screen(ArrayList<Field> _fields) {
this.fields = _fields;
}

public Field[] getFields() {
public ArrayList<Field> getFields() {
return fields;
}

Expand Down
38 changes: 34 additions & 4 deletions src/main/java/at/downardo/j3270Server/example/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;

import at.downardo.j3270Server.AIDClass.AID;
Expand Down Expand Up @@ -42,7 +44,7 @@ public void run() {
Telnet.NegotiateTelnet(out, in);

EBCDIC.CODEPAGE = "CP1148";

/*
Field[] fields = {
new Field(0,0,"HALLO WELT TEST €", false, true, false, "", Field.Colour.Blue, Field.Highlight.Blink),
new Field(1,0, "Name", false, true, false, ""),
Expand All @@ -61,8 +63,27 @@ public void run() {
new Field(6,0, "Test", false, false, false, ""),
new Field(22,0, "", false, true, false, "errormsg", Field.Colour.Red),
new Field(23,0, "PF3 Exit", false, true, false, "")

};
};*/
ArrayList<Field> fields = new ArrayList<Field>();
Collections.addAll(fields,
new Field(0,0,"HALLO WELT TEST €", false, true, false, "", Field.Colour.Blue, Field.Highlight.Blink),
new Field(1,0, "Name", false, true, false, ""),
new Field(1,13, "", true, false, false, "name", Field.Colour.Turquosie, Field.Highlight.ReverseVideo),
new Field(1,40, "", false, false, false),
new Field(2,0, "Age", false, true, false, ""),
new Field(2,13, "", true, false, false, "age", Field.Colour.Turquosie, Field.Highlight.ReverseVideo),
new Field(2,16, "", false, false, false),
new Field(3,0, "Company", false, true, false, ""),
new Field(3,13, "", true, false, false, "company", Field.Colour.Turquosie, Field.Highlight.ReverseVideo),
new Field(3,40, "", false, false, false),
new Field(4,0, "Password ", false, false, false, ""),
new Field(4, 13, "", true, false, true, "password"),
new Field(4,40, "",false,false,false),
new Field(5,0, "Test", false, true, false, ""),
new Field(6,0, "Test", false, false, false, ""),
new Field(22,0, "", false, true, false, "errormsg", Field.Colour.Red),
new Field(23,0, "PF3 Exit", false, true, false, "")
);

Validator nonBlank = new NonBlankValidator();
Validator isInteger = new IsIntegerValidator();
Expand All @@ -72,13 +93,22 @@ public void run() {
screen1Rules.put("age", new FieldRule(false, "", isInteger, false));
screen1Rules.put("password", new FieldRule(false, "", nonBlank, true));
screen1Rules.put("company", new FieldRule(true, "Must be changed!", nonBlank, true));

/*
Field[] fields2 = {
new Field(0,0,"HALLO WELT TEST WORLD 2", false, true, false, ""),
new Field(1,0, "Name", false, true, false, ""),
new Field(22,0, "", false, true, false, "errormsg"),
new Field(1,13, "", false, false, false, "")
};
*/

ArrayList<Field> fields2 = new ArrayList<Field>();
Collections.addAll(fields2,
new Field(0,0,"HALLO WELT TEST WORLD 2", false, true, false, ""),
new Field(1,0, "Name", false, true, false, ""),
new Field(22,0, "", false, true, false, "errormsg"),
new Field(1,13, "", false, false, false, "")
);

Screen screen = new Screen(fields);
Screen screen2 = new Screen(fields2);
Expand Down

0 comments on commit 665f187

Please sign in to comment.