public class NetworkTable extends java.lang.Object implements ITable, IRemote
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PORT
The default port that network tables operates on
|
static char |
PATH_SEPARATOR
The path separator for sub-tables and keys
|
Modifier and Type | Method and Description |
---|---|
void |
addConnectionListener(IRemoteConnectionListener listener,
boolean immediateNotify)
Register an object to listen for connection and disconnection events
|
void |
addSubTableListener(ITableListener listener)
This will immediately notify the listener of all current sub tables
|
void |
addTableListener(ITableListener listener)
Add a listener for changes to the table
|
void |
addTableListener(ITableListener listener,
boolean immediateNotify)
Add a listener for changes to the table
|
void |
addTableListener(java.lang.String key,
ITableListener listener,
boolean immediateNotify)
Add a listener for changes to a specific key the table
|
boolean |
containsKey(java.lang.String key)
Checks the table and tells if it contains the specified key
|
boolean |
containsSubTable(java.lang.String key) |
boolean |
getBoolean(java.lang.String key)
Returns the key that the name maps to.
|
boolean |
getBoolean(java.lang.String key,
boolean defaultValue)
Returns the key that the name maps to.
|
double |
getDouble(java.lang.String key)
Deprecated.
Returns the value at the specified key.
|
double |
getDouble(java.lang.String key,
double defaultValue)
Deprecated.
Returns the value at the specified key.
|
int |
getInt(java.lang.String key)
Deprecated.
Returns the value at the specified key.
|
int |
getInt(java.lang.String key,
int defaultValue)
Deprecated.
Returns the value at the specified key.
|
double |
getNumber(java.lang.String key)
Returns the key that the name maps to.
|
double |
getNumber(java.lang.String key,
double defaultValue)
Returns the key that the name maps to.
|
java.lang.String |
getString(java.lang.String key)
Returns the key that the name maps to.
|
java.lang.String |
getString(java.lang.String key,
java.lang.String defaultValue)
Returns the key that the name maps to.
|
ITable |
getSubTable(java.lang.String key)
Returns the table at the specified key.
|
static NetworkTable |
getTable(java.lang.String key)
Gets the table with the specified key.
|
java.lang.Object |
getValue(java.lang.String key)
Returns the key that the name maps to.
|
java.lang.Object |
getValue(java.lang.String key,
java.lang.Object defaultValue)
Returns the key that the name maps to.
|
static void |
initialize() |
boolean |
isConnected()
Get the current state of the objects connection
|
boolean |
isServer()
If the object is acting as a server
|
void |
putBoolean(java.lang.String key,
boolean value)
Maps the specified key to the specified value in this table.
|
void |
putDouble(java.lang.String key,
double value)
Deprecated.
Maps the specified key to the specified value in this table.
The key can not be null.
The value can be retrieved by calling the get method with a key that is equal to the original key.
|
void |
putInt(java.lang.String key,
int value)
Deprecated.
Maps the specified key to the specified value in this table.
The key can not be null.
The value can be retrieved by calling the get method with a key that is equal to the original key.
|
void |
putNumber(java.lang.String key,
double value)
Maps the specified key to the specified value in this table.
|
void |
putString(java.lang.String key,
java.lang.String value)
Maps the specified key to the specified value in this table.
|
void |
putValue(java.lang.String key,
java.lang.Object value)
Maps the specified key to the specified value in this table.
|
void |
removeConnectionListener(IRemoteConnectionListener listener)
Unregister a listener from connection events
|
void |
removeTableListener(ITableListener listener)
Remove a listener from receiving table events
|
void |
retrieveValue(java.lang.String key,
java.lang.Object externalValue) |
static void |
setClientMode()
set that network tables should be a client
This must be called before initalize or getTable
|
static void |
setIPAddress(java.lang.String address) |
static void |
setServerMode()
set that network tables should be a server
This must be called before initalize or getTable
|
static void |
setTableProvider(NetworkTableProvider provider)
set the table provider for static network tables methods
This must be called before initalize or getTable
|
static void |
setTeam(int team)
set the team the robot is configured for (this will set the ip address that network tables will connect to in client mode)
This must be called before initalize or getTable
|
java.lang.String |
toString() |
public static final char PATH_SEPARATOR
public static final int DEFAULT_PORT
public static void initialize() throws java.io.IOException
java.io.IOException
public static void setTableProvider(NetworkTableProvider provider)
public static void setServerMode()
public static void setClientMode()
public static void setTeam(int team)
team
- the team numberpublic static void setIPAddress(java.lang.String address)
address
- the adress that network tables will connect to in client modepublic static NetworkTable getTable(java.lang.String key)
key
- the key namepublic java.lang.String toString()
toString
in class java.lang.Object
public boolean isConnected()
IRemote
isConnected
in interface IRemote
public boolean isServer()
IRemote
public void addConnectionListener(IRemoteConnectionListener listener, boolean immediateNotify)
IRemote
addConnectionListener
in interface IRemote
listener
- the listener to be registerimmediateNotify
- if the listener object should be notified of the current connection statepublic void removeConnectionListener(IRemoteConnectionListener listener)
IRemote
removeConnectionListener
in interface IRemote
listener
- the listener to be unregisteredpublic void addTableListener(ITableListener listener)
ITable
addTableListener
in interface ITable
listener
- the listener to addpublic void addTableListener(ITableListener listener, boolean immediateNotify)
ITable
addTableListener
in interface ITable
listener
- the listener to addimmediateNotify
- if true then this listener will be notified of all current entries (marked as new)public void addTableListener(java.lang.String key, ITableListener listener, boolean immediateNotify)
ITable
addTableListener
in interface ITable
key
- the key to listen forlistener
- the listener to addimmediateNotify
- if true then this listener will be notified of all current entries (marked as new)public void addSubTableListener(ITableListener listener)
ITable
addSubTableListener
in interface ITable
public void removeTableListener(ITableListener listener)
ITable
removeTableListener
in interface ITable
listener
- the listener to be removedpublic ITable getSubTable(java.lang.String key)
getSubTable
in interface ITable
key
- the key namepublic boolean containsKey(java.lang.String key)
containsKey
in interface ITable
key
- the key to be checkedpublic boolean containsSubTable(java.lang.String key)
containsSubTable
in interface ITable
key
- the key to search forpublic void putNumber(java.lang.String key, double value)
public double getNumber(java.lang.String key) throws TableKeyNotDefinedException
getNumber
in interface ITable
key
- the key nameTableKeyNotDefinedException
- if the specified key is nullpublic double getNumber(java.lang.String key, double defaultValue)
public void putString(java.lang.String key, java.lang.String value)
public java.lang.String getString(java.lang.String key) throws TableKeyNotDefinedException
getString
in interface ITable
key
- the key nameTableKeyNotDefinedException
- if the specified key is nullpublic java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
public void putBoolean(java.lang.String key, boolean value)
putBoolean
in interface ITable
key
- the keyvalue
- the valuepublic boolean getBoolean(java.lang.String key) throws TableKeyNotDefinedException
getBoolean
in interface ITable
key
- the key nameTableKeyNotDefinedException
- if the specified key is nullpublic boolean getBoolean(java.lang.String key, boolean defaultValue)
getBoolean
in interface ITable
key
- the key namedefaultValue
- the default value if the key is nullpublic void retrieveValue(java.lang.String key, java.lang.Object externalValue)
retrieveValue
in interface ITable
public void putValue(java.lang.String key, java.lang.Object value)
public java.lang.Object getValue(java.lang.String key) throws TableKeyNotDefinedException
getValue
in interface ITable
key
- the key nameTableKeyNotDefinedException
- if the specified key is nullpublic java.lang.Object getValue(java.lang.String key, java.lang.Object defaultValue)
key
- the key namedefaultValue
- the default value if the key is nullpublic void putInt(java.lang.String key, int value)
public int getInt(java.lang.String key) throws TableKeyNotDefinedException
getInt
in interface ITable
key
- the keyTableKeyNotDefinedException
- if there is no value mapped to by the keyjava.lang.IllegalArgumentException
- if the value mapped to by the key is not an intjava.lang.IllegalArgumentException
- if the key is nullpublic int getInt(java.lang.String key, int defaultValue) throws TableKeyNotDefinedException
getInt
in interface ITable
key
- the keydefaultValue
- the value returned if the key is undefinedNetworkTableKeyNotDefined
- if there is no value mapped to by the keyjava.lang.IllegalArgumentException
- if the value mapped to by the key is not an intjava.lang.IllegalArgumentException
- if the key is nullTableKeyNotDefinedException
public void putDouble(java.lang.String key, double value)
public double getDouble(java.lang.String key) throws TableKeyNotDefinedException
getDouble
in interface ITable
key
- the keyNoSuchEleNetworkTableKeyNotDefinedmentException
- if there is no value mapped to by the keyjava.lang.IllegalArgumentException
- if the value mapped to by the key is not a doublejava.lang.IllegalArgumentException
- if the key is nullTableKeyNotDefinedException
public double getDouble(java.lang.String key, double defaultValue)
getDouble
in interface ITable
key
- the keydefaultValue
- the value returned if the key is undefinedNoSuchEleNetworkTableKeyNotDefinedmentException
- if there is no value mapped to by the keyjava.lang.IllegalArgumentException
- if the value mapped to by the key is not a doublejava.lang.IllegalArgumentException
- if the key is null