001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.net;
006
007import java.util.HashMap;
008import java.util.Map;
009
010/** Service data for MulticastServiceResolver. */
011public class ServiceData {
012  /**
013   * Constructs a ServiceData.
014   *
015   * @param ipv4Address ipv4Address
016   * @param port port
017   * @param serviceName found service name
018   * @param hostName found host name
019   * @param keys txt keys
020   * @param values txt values
021   */
022  public ServiceData(
023      long ipv4Address,
024      int port,
025      String serviceName,
026      String hostName,
027      String[] keys,
028      String[] values) {
029    this.m_serviceName = serviceName;
030    this.m_hostName = hostName;
031    this.m_port = port;
032    this.m_ipv4Address = ipv4Address;
033
034    m_txt = new HashMap<>();
035
036    for (int i = 0; i < keys.length; i++) {
037      m_txt.put(keys[i], values[i]);
038    }
039  }
040
041  public Map<String, String> getTxt() {
042    return m_txt;
043  }
044
045  public String getHostName() {
046    return m_hostName;
047  }
048
049  public String getServiceName() {
050    return m_serviceName;
051  }
052
053  public int getPort() {
054    return m_port;
055  }
056
057  public long getIpv4Address() {
058    return m_ipv4Address;
059  }
060
061  private final Map<String, String> m_txt;
062  private final long m_ipv4Address;
063  private final int m_port;
064  private final String m_serviceName;
065  private final String m_hostName;
066}