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.networktables;
006
007/** NetworkTables entry base implementation. */
008public abstract class EntryBase implements Subscriber, Publisher {
009  /**
010   * Constructor.
011   *
012   * @param handle handle
013   */
014  public EntryBase(int handle) {
015    m_handle = handle;
016  }
017
018  @Override
019  public boolean isValid() {
020    return m_handle != 0;
021  }
022
023  @Override
024  public int getHandle() {
025    return m_handle;
026  }
027
028  @Override
029  public void close() {
030    NetworkTablesJNI.release(m_handle);
031  }
032
033  @Override
034  public boolean exists() {
035    return NetworkTablesJNI.getTopicExists(m_handle);
036  }
037
038  @Override
039  public long getLastChange() {
040    return NetworkTablesJNI.getEntryLastChange(m_handle);
041  }
042
043  protected int m_handle;
044}