Skip to content

Commit fb9979d

Browse files
committed
Parse ints unsigned
1 parent 0564cfe commit fb9979d

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

src/io/calimero/gui/ConnectArguments.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Calimero GUI - A graphical user interface for the Calimero 3 tools
3-
Copyright (c) 2006, 2024 B. Malinowsky
3+
Copyright (c) 2006, 2025 B. Malinowsky
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -298,7 +298,7 @@ private String tryLookupKeyring(final String key, final String value)
298298
}
299299

300300
if (key.startsWith("user")) {
301-
final int user = Integer.parseInt(value);
301+
final int user = Integer.parseUnsignedInt(value);
302302
byte[] pwdData = null;
303303
if (user == 1) {
304304
final var device = keyring.devices().get(hostIA);

src/io/calimero/gui/ConnectDialog.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Calimero GUI - A graphical user interface for the Calimero 3 tools
3-
Copyright (c) 2006, 2024 B. Malinowsky
3+
Copyright (c) 2006, 2025 B. Malinowsky
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -325,7 +325,7 @@ else if (!h.isEmpty()) {
325325
// if no/invalid port is supplied for KNXnet/IP, we use default port
326326
int port;
327327
try {
328-
port = Integer.parseInt(p);
328+
port = Integer.parseUnsignedInt(p);
329329
} catch (final NumberFormatException ex) {
330330
port = KNXnetIPConnection.DEFAULT_PORT;
331331
}

src/io/calimero/gui/KeyringTab.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Calimero GUI - A graphical user interface for the Calimero 3 tools
3-
Copyright (c) 2019, 2024 B. Malinowsky
3+
Copyright (c) 2019, 2025 B. Malinowsky
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -190,7 +190,7 @@ private void updateInterfaceSelection(final SelectionEvent e) {
190190
final TableItem current = (TableItem) e.item;
191191

192192
if (current.getChecked()) {
193-
user = Integer.parseInt(current.getText(2));
193+
user = Integer.parseUnsignedInt(current.getText(2));
194194
try {
195195
address = new IndividualAddress(current.getText(1));
196196
}

src/io/calimero/gui/MemoryEditor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Calimero GUI - A graphical user interface for the Calimero 3 tools
3-
Copyright (c) 2017, 2024 B. Malinowsky
3+
Copyright (c) 2017, 2025 B. Malinowsky
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -247,7 +247,7 @@ protected void initTableBottom(final Composite parent, final Sash sash)
247247
if (start.getText().isEmpty() || bytes.getText().isEmpty())
248248
return;
249249
read.setEnabled(false);
250-
readMemory(Long.parseLong(start.getText(), 16), Integer.parseInt(bytes.getText()));
250+
readMemory(Long.parseUnsignedLong(start.getText(), 16), Integer.parseUnsignedInt(bytes.getText()));
251251
}));
252252

253253
bytes.addTraverseListener(traverseEvent -> {
@@ -485,8 +485,8 @@ private void updateMemoryValue(final TableItem item, final int row, final int co
485485
{
486486
if (value.isEmpty())
487487
return;
488-
final int v = Integer.parseInt(value, 16);
489-
if (v != Integer.parseInt(item.getText(column), 16)) {
488+
final int v = Integer.parseUnsignedInt(value, 16);
489+
if (v != Integer.parseUnsignedInt(item.getText(column), 16)) {
490490
final int location = viewerStartOffset + row * viewerColumns + column;
491491
addToModifiedList(location, v);
492492
item.setText(column, value);
@@ -498,12 +498,12 @@ private void updateBinary(final String text)
498498
if (text.isEmpty())
499499
binary.setText("");
500500
else
501-
binary.setText("0b" + Integer.toBinaryString((1 << 8) | Integer.parseInt(text, 16)).substring(1));
501+
binary.setText("0b" + Integer.toBinaryString((1 << 8) | Integer.parseUnsignedInt(text, 16)).substring(1));
502502
}
503503

504504
private void setViewerStartOffset()
505505
{
506-
final int offset = Integer.parseInt(setStartOffset.getText(), 16);
506+
final int offset = Integer.parseUnsignedInt(setStartOffset.getText(), 16);
507507
while (viewerStartOffset > offset) {
508508
viewerStartOffset -= viewerColumns;
509509
addMemoryRow(true);

src/io/calimero/gui/PropertyEditorTab.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Calimero GUI - A graphical user interface for the Calimero 3 tools
3-
Copyright (c) 2015, 2024 B. Malinowsky
3+
Copyright (c) 2015, 2025 B. Malinowsky
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -512,7 +512,7 @@ private void showPropertyPage(final int objectIndex, final int pid)
512512
override.addSelectionListener(adapt(e -> elems.setEnabled(override.getSelection())));
513513

514514
set.addSelectionListener(adapt(e -> writeValues(objectIndex, pid, value.getText(),
515-
override.getSelection() ? Integer.parseInt(elems.getText()) : -1, p)));
515+
override.getSelection() ? Integer.parseUnsignedInt(elems.getText()) : -1, p)));
516516

517517
singleLineLabel("(Maximum elements " + (d.maxElements() > 0 ? d.maxElements() : "unknown") + ")");
518518

@@ -767,7 +767,7 @@ private void onItemPaint(final Event event)
767767
final String io = (String) event.item.getData(ObjectIndex);
768768
final String objType = (String) event.item.getData(ObjectType);
769769
final String header = "Interface Object " + io + " - "
770-
+ PropertyClient.getObjectTypeName(Integer.parseInt(objType)) + " (Object Type "
770+
+ PropertyClient.getObjectTypeName(Integer.parseUnsignedInt(objType)) + " (Object Type "
771771
+ objType + ")";
772772
final GC gc = new GC(table);
773773
final Point extent = gc.stringExtent(header);
@@ -802,9 +802,9 @@ private void onMouseDown(final Event event)
802802
else if (e.type == SWT.Traverse) {
803803
switch (e.detail) {
804804
case SWT.TRAVERSE_RETURN:
805-
final int objectIndex = Integer.parseInt((String) item.getData(ObjectIndex));
806-
final int objectType = Integer.parseInt((String) item.getData(ObjectType));
807-
final int pid = Integer.parseInt(item.getText(Columns.Pid.ordinal()));
805+
final int objectIndex = Integer.parseUnsignedInt((String) item.getData(ObjectIndex));
806+
final int objectType = Integer.parseUnsignedInt((String) item.getData(ObjectType));
807+
final int pid = Integer.parseUnsignedInt(item.getText(Columns.Pid.ordinal()));
808808
final var definition = getDefinition(objectType, pid).orElse(unknown);
809809
writeValues(objectIndex, pid, text.getText(), -1, definition);
810810
// fall through
@@ -849,9 +849,9 @@ private void updateDptBounds(final String objType, final String pid)
849849
{
850850
bounds.removeAll();
851851

852-
final Optional<PropertyClient.Property> opt = getDefinition(Integer.parseInt(objType), Integer.parseInt(pid));
853-
if (opt.isPresent()) {
854-
final PropertyClient.Property p = opt.get();
852+
final var optProp = getDefinition(Integer.parseUnsignedInt(objType), Integer.parseUnsignedInt(pid));
853+
if (optProp.isPresent()) {
854+
final PropertyClient.Property p = optProp.get();
855855
p.dpt().flatMap(dpt -> createTranslator(0, dpt)).or(() -> createTranslator(p.pdt()))
856856
.ifPresentOrElse(t -> {
857857
final DPT dpt = t.getType();

0 commit comments

Comments
 (0)