From a2d972fc2270b0735fc24a7d9e2abab7e7053d46 Mon Sep 17 00:00:00 2001 From: Michal Date: Thu, 3 Sep 2026 00:03:13 +0200 Subject: [PATCH] =?UTF-8?q?pridano=20vy=C4=8D=C3=ADt=C3=A1n=C3=AD=20u?= =?UTF-8?q?=C5=BEivatelskeho=20popisu=20portu=20-=20prid=C3=A1ny=20prom?= =?UTF-8?q?=C4=9Bn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/jnet/lib/object/Interface.java | 68 ++++++++++++++++---- 1 file changed, 56 insertions(+), 12 deletions(-) diff --git a/src/main/java/jnet/lib/object/Interface.java b/src/main/java/jnet/lib/object/Interface.java index bcaecbc..8f9b963 100644 --- a/src/main/java/jnet/lib/object/Interface.java +++ b/src/main/java/jnet/lib/object/Interface.java @@ -5,37 +5,67 @@ import java.io.Serializable; public class Interface implements Serializable { private int id; - private String description; + private String description; // původní (plný) popis z ifDescr + private String shortDescription; // zkrácená verze popisu private String operStatus; private String speed; private String type; private String macAddress; private String adminStatus; private String lastChangeTime; + private String alias; // uživatelský alias (ifAlias) - public Interface(int id, String description, String operStatus, String speed, String type, String macAddress, String adminStatus, String lastChangeTime) { + // Hlavní konstruktor se všemi parametry včetně shortDescription + public Interface(int id, String description, String shortDescription, String operStatus, + String speed, String type, String macAddress, String adminStatus, + String lastChangeTime, String alias) { this.id = id; this.description = description; + this.shortDescription = shortDescription; this.operStatus = operStatus; this.speed = speed; this.type = type; this.macAddress = macAddress; this.adminStatus = adminStatus; this.lastChangeTime = lastChangeTime; + this.alias = alias; + } + + // Konstruktor pro zpětnou kompatibilitu (shortDescription = description) + public Interface(int id, String description, String operStatus, String speed, String type, + String macAddress, String adminStatus, String lastChangeTime, String alias) { + this(id, description, description, operStatus, speed, type, macAddress, + adminStatus, lastChangeTime, alias); + } + + // Původní konstruktor bez aliasu (pro zachování kompatibility) + public Interface(int id, String description, String operStatus, String speed, String type, + String macAddress, String adminStatus, String lastChangeTime) { + this(id, description, description, operStatus, speed, type, macAddress, + adminStatus, lastChangeTime, null); } @Override public String toString() { - return "Interface ID: " + id + "\n" - + "Description: " + description + "\n" - + "Operational Status: " + operStatus + "\n" - + "Speed: " + speed + "\n" - + "Type: " + type + "\n" - + "MAC Address: " + macAddress + "\n" - + "Administrative Status: " + adminStatus + "\n" - + "Last Link Change: " + lastChangeTime + "\n"; + StringBuilder sb = new StringBuilder(); + sb.append("Interface ID: ").append(id).append("\n"); + sb.append("Description: ").append(description).append("\n"); + if (!shortDescription.equals(description)) { + sb.append("Short Description: ").append(shortDescription).append("\n"); + } + if (alias != null && !alias.isEmpty() && !alias.equals(shortDescription)) { + sb.append("Alias: ").append(alias).append("\n"); + } + sb.append("Operational Status: ").append(operStatus).append("\n"); + sb.append("Speed: ").append(speed).append("\n"); + sb.append("Type: ").append(type).append("\n"); + sb.append("MAC Address: ").append(macAddress).append("\n"); + sb.append("Administrative Status: ").append(adminStatus).append("\n"); + sb.append("Last Link Change: ").append(lastChangeTime).append("\n"); + return sb.toString(); } + // Gettery a settery public int getId() { return id; } @@ -52,6 +82,14 @@ public class Interface implements Serializable { this.description = description; } + public String getShortDescription() { + return shortDescription; + } + + public void setShortDescription(String shortDescription) { + this.shortDescription = shortDescription; + } + public String getOperStatus() { return operStatus; } @@ -99,6 +137,12 @@ public class Interface implements Serializable { public void setLastChangeTime(String lastChangeTime) { this.lastChangeTime = lastChangeTime; } - - + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } }