diff --git a/wpilibc/shared/include/SmartDashboard/SmartDashboard.h b/wpilibc/shared/include/SmartDashboard/SmartDashboard.h index 6e7edd0cb1..ff741a3e85 100644 --- a/wpilibc/shared/include/SmartDashboard/SmartDashboard.h +++ b/wpilibc/shared/include/SmartDashboard/SmartDashboard.h @@ -20,22 +20,65 @@ class SmartDashboard : public SensorBase { public: static void init(); + static bool ContainsKey(llvm::StringRef key); + + static std::vector GetKeys(int types = 0); + + static void SetPersistent(llvm::StringRef key); + static void ClearPersistent(llvm::StringRef key); + static bool IsPersistent(llvm::StringRef key); + + static void SetFlags(llvm::StringRef key, unsigned int flags); + static void ClearFlags(llvm::StringRef key, unsigned int flags); + static unsigned int GetFlags(llvm::StringRef key); + + static void Delete(llvm::StringRef key); + static void PutData(llvm::StringRef key, Sendable* data); static void PutData(NamedSendable* value); static Sendable* GetData(llvm::StringRef keyName); - static void PutBoolean(llvm::StringRef keyName, bool value); + static bool PutBoolean(llvm::StringRef keyName, bool value); + static bool SetDefaultBoolean(llvm::StringRef key, bool defaultValue); static bool GetBoolean(llvm::StringRef keyName, bool defaultValue); - static void PutNumber(llvm::StringRef keyName, double value); + static bool PutNumber(llvm::StringRef keyName, double value); + static bool SetDefaultNumber(llvm::StringRef key, double defaultValue); static double GetNumber(llvm::StringRef keyName, double defaultValue); - static void PutString(llvm::StringRef keyName, llvm::StringRef value); + static bool PutString(llvm::StringRef keyName, llvm::StringRef value); + static bool SetDefaultString(llvm::StringRef key, + llvm::StringRef defaultValue); static std::string GetString(llvm::StringRef keyName, llvm::StringRef defaultValue); - static void PutValue(llvm::StringRef keyName, + static bool PutBooleanArray(llvm::StringRef key, llvm::ArrayRef value); + static bool SetDefaultBooleanArray(llvm::StringRef key, + llvm::ArrayRef defaultValue); + static std::vector GetBooleanArray(llvm::StringRef key, + llvm::ArrayRef defaultValue); + + static bool PutNumberArray(llvm::StringRef key, llvm::ArrayRef value); + static bool SetDefaultNumberArray(llvm::StringRef key, + llvm::ArrayRef defaultValue); + static std::vector GetNumberArray( + llvm::StringRef key, llvm::ArrayRef defaultValue); + + static bool PutStringArray(llvm::StringRef key, + llvm::ArrayRef value); + static bool SetDefaultStringArray(llvm::StringRef key, + llvm::ArrayRef defaultValue); + static std::vector GetStringArray( + llvm::StringRef key, llvm::ArrayRef defaultValue); + + static bool PutRaw(llvm::StringRef key, llvm::StringRef value); + static bool SetDefaultRaw(llvm::StringRef key, llvm::StringRef defaultValue); + static std::string GetRaw(llvm::StringRef key, llvm::StringRef defaultValue); + + static bool PutValue(llvm::StringRef keyName, std::shared_ptr value); + static bool SetDefaultValue(llvm::StringRef key, + std::shared_ptr defaultValue); static std::shared_ptr GetValue(llvm::StringRef keyName); private: diff --git a/wpilibc/shared/src/SmartDashboard/SmartDashboard.cpp b/wpilibc/shared/src/SmartDashboard/SmartDashboard.cpp index 231c505f69..eb8a2efd3f 100644 --- a/wpilibc/shared/src/SmartDashboard/SmartDashboard.cpp +++ b/wpilibc/shared/src/SmartDashboard/SmartDashboard.cpp @@ -21,6 +21,92 @@ void SmartDashboard::init() { HLUsageReporting::ReportSmartDashboard(); } +/** + * Determines whether the given key is in this table. + * + * @param key the key to search for + * @return true if the table as a value assigned to the given key + */ +bool SmartDashboard::ContainsKey(llvm::StringRef key) { + return m_table->ContainsKey(key); +} + +/** + * @param types bitmask of types; 0 is treated as a "don't care". + * @return keys currently in the table + */ +std::vector SmartDashboard::GetKeys(int types) { + return m_table->GetKeys(types); +} + +/** + * Makes a key's value persistent through program restarts. + * + * @param key the key to make persistent + */ +void SmartDashboard::SetPersistent(llvm::StringRef key) { + m_table->SetPersistent(key); +} + +/** + * Stop making a key's value persistent through program restarts. + * The key cannot be null. + * + * @param key the key name + */ +void SmartDashboard::ClearPersistent(llvm::StringRef key) { + m_table->ClearPersistent(key); +} + +/** + * Returns whether the value is persistent through program restarts. + * The key cannot be null. + * + * @param key the key name + */ +bool SmartDashboard::IsPersistent(llvm::StringRef key) { + return m_table->IsPersistent(key); +} + +/** + * Sets flags on the specified key in this table. The key can + * not be null. + * + * @param key the key name + * @param flags the flags to set (bitmask) + */ +void SmartDashboard::SetFlags(llvm::StringRef key, unsigned int flags) { + m_table->SetFlags(key, flags); +} + +/** + * Clears flags on the specified key in this table. The key can + * not be null. + * + * @param key the key name + * @param flags the flags to clear (bitmask) + */ +void SmartDashboard::ClearFlags(llvm::StringRef key, unsigned int flags) { + m_table->ClearFlags(key, flags); +} + +/** + * Returns the flags for the specified key. + * + * @param key the key name + * @return the flags, or 0 if the key is not defined + */ +unsigned int SmartDashboard::GetFlags(llvm::StringRef key) { + return m_table->GetFlags(key); +} + +/** + * Deletes the specified key in this table. + * + * @param key the key name + */ +void SmartDashboard::Delete(llvm::StringRef key) { m_table->Delete(key); } + /** * Maps the specified key to the specified value in this table. * @@ -83,10 +169,22 @@ Sendable* SmartDashboard::GetData(llvm::StringRef key) { * * @param keyName the key * @param value the value + * @return False if the table key already exists with a different type */ -void SmartDashboard::PutValue(llvm::StringRef keyName, +bool SmartDashboard::PutValue(llvm::StringRef keyName, std::shared_ptr value) { - m_table->PutValue(keyName, value); + return m_table->PutValue(keyName, value); +} + +/** + * Gets the current value in the table, setting it if it does not exist. + * @param key the key + * @param defaultValue the default value to set if key doesn't exist. + * @returns False if the table key exists with a different type + */ +bool SmartDashboard::SetDefaultValue(llvm::StringRef key, + std::shared_ptr defaultValue) { + return m_table->SetDefaultValue(key, defaultValue); } /** @@ -108,9 +206,20 @@ std::shared_ptr SmartDashboard::GetValue(llvm::StringRef keyName) { * * @param keyName the key * @param value the value + * @return False if the table key already exists with a different type */ -void SmartDashboard::PutBoolean(llvm::StringRef keyName, bool value) { - m_table->PutBoolean(keyName, value); +bool SmartDashboard::PutBoolean(llvm::StringRef keyName, bool value) { + return m_table->PutBoolean(keyName, value); +} + +/** + * Gets the current value in the table, setting it if it does not exist. + * @param key the key + * @param defaultValue the default value to set if key doesn't exist. + * @returns False if the table key exists with a different type + */ +bool SmartDashboard::SetDefaultBoolean(llvm::StringRef key, bool defaultValue) { + return m_table->SetDefaultBoolean(key, defaultValue); } /** @@ -133,9 +242,21 @@ bool SmartDashboard::GetBoolean(llvm::StringRef keyName, bool defaultValue) { * * @param keyName the key * @param value the value + * @return False if the table key already exists with a different type */ -void SmartDashboard::PutNumber(llvm::StringRef keyName, double value) { - m_table->PutNumber(keyName, value); +bool SmartDashboard::PutNumber(llvm::StringRef keyName, double value) { + return m_table->PutNumber(keyName, value); +} + +/** + * Gets the current value in the table, setting it if it does not exist. + * @param key the key + * @param defaultValue the default value to set if key doesn't exist. + * @returns False if the table key exists with a different type + */ +bool SmartDashboard::SetDefaultNumber(llvm::StringRef key, + double defaultValue) { + return m_table->SetDefaultNumber(key, defaultValue); } /** @@ -158,9 +279,21 @@ double SmartDashboard::GetNumber(llvm::StringRef keyName, double defaultValue) { * * @param keyName the key * @param value the value + * @return False if the table key already exists with a different type */ -void SmartDashboard::PutString(llvm::StringRef keyName, llvm::StringRef value) { - m_table->PutString(keyName, value); +bool SmartDashboard::PutString(llvm::StringRef keyName, llvm::StringRef value) { + return m_table->PutString(keyName, value); +} + +/** + * Gets the current value in the table, setting it if it does not exist. + * @param key the key + * @param defaultValue the default value to set if key doesn't exist. + * @returns False if the table key exists with a different type + */ +bool SmartDashboard::SetDefaultString(llvm::StringRef key, + llvm::StringRef defaultValue) { + return m_table->SetDefaultString(key, defaultValue); } /** @@ -175,3 +308,162 @@ std::string SmartDashboard::GetString(llvm::StringRef keyName, llvm::StringRef defaultValue) { return m_table->GetString(keyName, defaultValue); } + +/** + * Put a boolean array in the table + * @param key the key to be assigned to + * @param value the value that will be assigned + * @return False if the table key already exists with a different type + * + * @note The array must be of int's rather than of bool's because + * std::vector is special-cased in C++. 0 is false, any + * non-zero value is true. + */ +bool SmartDashboard::PutBooleanArray(llvm::StringRef key, + llvm::ArrayRef value) { + return m_table->PutBooleanArray(key, value); +} + +/** + * Gets the current value in the table, setting it if it does not exist. + * @param key the key + * @param defaultValue the default value to set if key doesn't exist. + * @returns False if the table key exists with a different type + */ +bool SmartDashboard::SetDefaultBooleanArray(llvm::StringRef key, + llvm::ArrayRef defaultValue) { + return m_table->SetDefaultBooleanArray(key, defaultValue); +} + +/** + * Returns the boolean array the key maps to. If the key does not exist or is + * of different type, it will return the default value. + * @param key the key to look up + * @param defaultValue the value to be returned if no value is found + * @return the value associated with the given key or the given default value + * if there is no value associated with the key + * + * @note This makes a copy of the array. If the overhead of this is a + * concern, use GetValue() instead. + * + * @note The returned array is std::vector instead of std::vector + * because std::vector is special-cased in C++. 0 is false, any + * non-zero value is true. + */ +std::vector SmartDashboard::GetBooleanArray( + llvm::StringRef key, llvm::ArrayRef defaultValue) { + return m_table->GetBooleanArray(key, defaultValue); +} + +/** + * Put a number array in the table + * @param key the key to be assigned to + * @param value the value that will be assigned + * @return False if the table key already exists with a different type + */ +bool SmartDashboard::PutNumberArray(llvm::StringRef key, + llvm::ArrayRef value) { + return m_table->PutNumberArray(key, value); +} + +/** + * Gets the current value in the table, setting it if it does not exist. + * @param key the key + * @param defaultValue the default value to set if key doesn't exist. + * @returns False if the table key exists with a different type + */ +bool SmartDashboard::SetDefaultNumberArray( + llvm::StringRef key, llvm::ArrayRef defaultValue) { + return m_table->SetDefaultNumberArray(key, defaultValue); +} + +/** + * Returns the number array the key maps to. If the key does not exist or is + * of different type, it will return the default value. + * @param key the key to look up + * @param defaultValue the value to be returned if no value is found + * @return the value associated with the given key or the given default value + * if there is no value associated with the key + * + * @note This makes a copy of the array. If the overhead of this is a + * concern, use GetValue() instead. + */ +std::vector SmartDashboard::GetNumberArray( + llvm::StringRef key, llvm::ArrayRef defaultValue) { + return m_table->GetNumberArray(key, defaultValue); +} + +/** + * Put a string array in the table + * @param key the key to be assigned to + * @param value the value that will be assigned + * @return False if the table key already exists with a different type + */ +bool SmartDashboard::PutStringArray(llvm::StringRef key, + llvm::ArrayRef value) { + return m_table->PutStringArray(key, value); +} + +/** + * Gets the current value in the table, setting it if it does not exist. + * @param key the key + * @param defaultValue the default value to set if key doesn't exist. + * @returns False if the table key exists with a different type + */ +bool SmartDashboard::SetDefaultStringArray( + llvm::StringRef key, llvm::ArrayRef defaultValue) { + return m_table->SetDefaultStringArray(key, defaultValue); +} + +/** + * Returns the string array the key maps to. If the key does not exist or is + * of different type, it will return the default value. + * @param key the key to look up + * @param defaultValue the value to be returned if no value is found + * @return the value associated with the given key or the given default value + * if there is no value associated with the key + * + * @note This makes a copy of the array. If the overhead of this is a + * concern, use GetValue() instead. + */ +std::vector SmartDashboard::GetStringArray( + llvm::StringRef key, llvm::ArrayRef defaultValue) { + return m_table->GetStringArray(key, defaultValue); +} + +/** + * Put a raw value (byte array) in the table + * @param key the key to be assigned to + * @param value the value that will be assigned + * @return False if the table key already exists with a different type + */ +bool SmartDashboard::PutRaw(llvm::StringRef key, llvm::StringRef value) { + return m_table->PutRaw(key, value); +} + +/** + * Gets the current value in the table, setting it if it does not exist. + * @param key the key + * @param defaultValue the default value to set if key doesn't exist. + * @returns False if the table key exists with a different type + */ +bool SmartDashboard::SetDefaultRaw(llvm::StringRef key, + llvm::StringRef defaultValue) { + return m_table->SetDefaultRaw(key, defaultValue); +} + +/** + * Returns the raw value (byte array) the key maps to. If the key does not + * exist or is of different type, it will return the default value. + * @param key the key to look up + * @param defaultValue the value to be returned if no value is found + * @return the value associated with the given key or the given default value + * if there is no value associated with the key + * + * @note This makes a copy of the raw contents. If the overhead of this is a + * concern, use GetValue() instead. + */ +std::string SmartDashboard::GetRaw(llvm::StringRef key, + llvm::StringRef defaultValue) { + return m_table->GetRaw(key, defaultValue); +} diff --git a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.java b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.java index df4e8281bf..d451719b67 100644 --- a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.java +++ b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.java @@ -7,8 +7,10 @@ package edu.wpi.first.wpilibj.smartdashboard; +import java.nio.ByteBuffer; import java.util.Hashtable; import java.util.NoSuchElementException; +import java.util.Set; import edu.wpi.first.wpilibj.HLUsageReporting; import edu.wpi.first.wpilibj.NamedSendable; @@ -89,123 +91,499 @@ public class SmartDashboard { } /** - * 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. + * Checks the table and tells if it contains the specified key. * - * @param key the key - * @param value the value - * @throws IllegalArgumentException if key is null + * @param key the key to search for + * @return true if the table as a value assigned to the given key */ - public static void putBoolean(String key, boolean value) { - table.putBoolean(key, value); + public static boolean containsKey(String key) { + return table.containsKey(key); } /** - * Returns the value at the specified key. - * - * @param key the key - * @return the value - * @throws NetworkTableKeyNotDefined if there is no value mapped to by the key - * @throws IllegalArgumentException if the value mapped to by the key is not a boolean - * @throws IllegalArgumentException if the key is null + * @param types bitmask of types; 0 is treated as a "don't care". + * @return keys currently in the table */ + public Set getKeys(int types) { + return table.getKeys(types); + } + + /** + * @return keys currently in the table. + */ + public Set getKeys() { + return table.getKeys(); + } + + /** + * Makes a key's value persistent through program restarts. + * The key cannot be null. + * + * @param key the key name + */ + public void setPersistent(String key) { + table.setPersistent(key); + } + + /** + * Stop making a key's value persistent through program restarts. + * The key cannot be null. + * + * @param key the key name + */ + public void clearPersistent(String key) { + table.clearPersistent(key); + } + + /** + * Returns whether the value is persistent through program restarts. + * The key cannot be null. + * + * @param key the key name + * @return True if the value is persistent. + */ + public boolean isPersistent(String key) { + return table.isPersistent(key); + } + + /** + * Sets flags on the specified key in this table. The key can + * not be null. + * + * @param key the key name + * @param flags the flags to set (bitmask) + */ + public void setFlags(String key, int flags) { + table.setFlags(key, flags); + } + + /** + * Clears flags on the specified key in this table. The key can + * not be null. + * + * @param key the key name + * @param flags the flags to clear (bitmask) + */ + public void clearFlags(String key, int flags) { + table.clearFlags(key, flags); + } + + /** + * Returns the flags for the specified key. + * + * @param key the key name + * @return the flags, or 0 if the key is not defined + */ + public int getFlags(String key) { + return table.getFlags(key); + } + + /** + * Deletes the specified key in this table. The key can + * not be null. + * + * @param key the key name + */ + public void delete(String key) { + table.delete(key); + } + + /** + * Put a boolean in the table. + * @param key the key to be assigned to + * @param value the value that will be assigned + * @return False if the table key already exists with a different type + */ + public static boolean putBoolean(String key, boolean value) { + return table.putBoolean(key, value); + } + + /** + * Gets the current value in the table, setting it if it does not exist. + * @param key the key + * @param defaultValue the default value to set if key doens't exist. + * @return False if the table key exists with a different type + */ + public boolean setDefaultBoolean(String key, boolean defaultValue) { + return table.setDefaultBoolean(key, defaultValue); + } + + /** + * Returns the boolean the key maps to. + * @param key the key to look up + * @return the value associated with the given key + * @throws TableKeyNotDefinedException if there is no value associated with + * the given key + * @deprecated This exception-raising method has been replaced by the + * default-taking method {@link #getBoolean(String, boolean)}. + */ + @Deprecated public static boolean getBoolean(String key) throws TableKeyNotDefinedException { return table.getBoolean(key); } /** - * Returns the value at the specified key. - * - * @param key the key - * @param defaultValue returned if the key doesn't exist - * @return the value - * @throws IllegalArgumentException if the value mapped to by the key is not a boolean - * @throws IllegalArgumentException if the key is null + * Returns the boolean the key maps to. If the key does not exist or is of + * different type, it will return the default value. + * @param key the key to look up + * @param defaultValue the value to be returned if no value is found + * @return the value associated with the given key or the given default value + * if there is no value associated with the key */ public static boolean getBoolean(String key, boolean defaultValue) { return table.getBoolean(key, defaultValue); } /** - * 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. - * - * @param key the key - * @param value the value - * @throws IllegalArgumentException if key is null + * Put a number in the table. + * @param key the key to be assigned to + * @param value the value that will be assigned + * @return False if the table key already exists with a different type */ - public static void putNumber(String key, double value) { - table.putNumber(key, value); + public static boolean putNumber(String key, double value) { + return table.putNumber(key, value); } /** - * Returns the value at the specified key. - * + * Gets the current value in the table, setting it if it does not exist. * @param key the key - * @return the value - * @throws TableKeyNotDefinedException if there is no value mapped to by the key - * @throws IllegalArgumentException if the value mapped to by the key is not a double - * @throws IllegalArgumentException if the key is null + * @param defaultValue the default value to set if key doens't exist. + * @return False if the table key exists with a different type */ + public boolean setDefaultNumber(String key, double defaultValue) { + return table.setDefaultNumber(key, defaultValue); + } + + /** + * Returns the number the key maps to. + * @param key the key to look up + * @return the value associated with the given key + * @throws TableKeyNotDefinedException if there is no value associated with + * the given key + * @deprecated This exception-raising method has been replaced by the + * default-taking method {@link #getNumber(String, double)}. + */ + @Deprecated public static double getNumber(String key) throws TableKeyNotDefinedException { return table.getNumber(key); } /** - * Returns the value at the specified key. - * - * @param key the key - * @param defaultValue the value returned if the key is undefined - * @return the value - * @throws NetworkTableKeyNotDefined if there is no value mapped to by the key - * @throws IllegalArgumentException if the value mapped to by the key is not a double - * @throws IllegalArgumentException if the key is null + * Returns the number the key maps to. If the key does not exist or is of + * different type, it will return the default value. + * @param key the key to look up + * @param defaultValue the value to be returned if no value is found + * @return the value associated with the given key or the given default value + * if there is no value associated with the key */ public static double getNumber(String key, double defaultValue) { return table.getNumber(key, defaultValue); } /** - * Maps the specified key to the specified value in this table. Neither the key nor the value can - * be null. The value can be retrieved by calling the get method with a key that is equal to the - * original key. - * - * @param key the key - * @param value the value - * @throws IllegalArgumentException if key or value is null + * Put a string in the table. + * @param key the key to be assigned to + * @param value the value that will be assigned + * @return False if the table key already exists with a different type */ - public static void putString(String key, String value) { - table.putString(key, value); + public static boolean putString(String key, String value) { + return table.putString(key, value); } /** - * Returns the value at the specified key. - * + * Gets the current value in the table, setting it if it does not exist. * @param key the key - * @return the value - * @throws NetworkTableKeyNotDefined if there is no value mapped to by the key - * @throws IllegalArgumentException if the value mapped to by the key is not a string - * @throws IllegalArgumentException if the key is null + * @param defaultValue the default value to set if key doens't exist. + * @return False if the table key exists with a different type */ + public boolean setDefaultString(String key, String defaultValue) { + return table.setDefaultString(key, defaultValue); + } + + /** + * Returns the string the key maps to. + * @param key the key to look up + * @return the value associated with the given key + * @throws TableKeyNotDefinedException if there is no value associated with + * the given key + * @deprecated This exception-raising method has been replaced by the + * default-taking method {@link #getString(String, String)}. + */ + @Deprecated public static String getString(String key) throws TableKeyNotDefinedException { return table.getString(key); } /** - * Returns the value at the specified key. - * - * @param key the key - * @param defaultValue The value returned if the key is undefined - * @return the value - * @throws NetworkTableKeyNotDefined if there is no value mapped to by the key - * @throws IllegalArgumentException if the value mapped to by the key is not a string - * @throws IllegalArgumentException if the key is null + * Returns the string the key maps to. If the key does not exist or is of + * different type, it will return the default value. + * @param key the key to look up + * @param defaultValue the value to be returned if no value is found + * @return the value associated with the given key or the given default value + * if there is no value associated with the key */ public static String getString(String key, String defaultValue) { return table.getString(key, defaultValue); } + /** + * Put a boolean array in the table. + * @param key the key to be assigned to + * @param value the value that will be assigned + * @return False if the table key already exists with a different type + */ + public boolean putBooleanArray(String key, boolean[] value) { + return table.putBooleanArray(key, value); + } + /** + * Put a boolean array in the table. + * @param key the key to be assigned to + * @param value the value that will be assigned + * @return False if the table key already exists with a different type + */ + public boolean putBooleanArray(String key, Boolean[] value) { + return table.putBooleanArray(key, value); + } + + /** + * Gets the current value in the table, setting it if it does not exist. + * @param key the key + * @param defaultValue the default value to set if key doens't exist. + * @return False if the table key exists with a different type + */ + public boolean setDefaultBooleanArray(String key, boolean[] defaultValue) { + return table.setDefaultBooleanArray(key, defaultValue); + } + + /** + * Gets the current value in the table, setting it if it does not exist. + * @param key the key + * @param defaultValue the default value to set if key doens't exist. + * @return False if the table key exists with a different type + */ + public boolean setDefaultBooleanArray(String key, Boolean[] defaultValue) { + return table.setDefaultBooleanArray(key, defaultValue); + } + + /** + * Returns the boolean array the key maps to. + * @param key the key to look up + * @return the value associated with the given key + * @throws TableKeyNotDefinedException if there is no value associated with + * the given key + * @deprecated This exception-raising method has been replaced by the + * default-taking method {@link #getBooleanArray(String, boolean[])}. + */ + @Deprecated + public boolean[] getBooleanArray(String key) throws TableKeyNotDefinedException { + return table.getBooleanArray(key); + } + + /** + * Returns the boolean array the key maps to. If the key does not exist or is + * of different type, it will return the default value. + * @param key the key to look up + * @param defaultValue the value to be returned if no value is found + * @return the value associated with the given key or the given default value + * if there is no value associated with the key + */ + public boolean[] getBooleanArray(String key, boolean[] defaultValue) { + return table.getBooleanArray(key, defaultValue); + } + + /** + * Returns the boolean array the key maps to. If the key does not exist or is + * of different type, it will return the default value. + * @param key the key to look up + * @param defaultValue the value to be returned if no value is found + * @return the value associated with the given key or the given default value + * if there is no value associated with the key + */ + public Boolean[] getBooleanArray(String key, Boolean[] defaultValue) { + return table.getBooleanArray(key, defaultValue); + } + + /** + * Put a number array in the table. + * @param key the key to be assigned to + * @param value the value that will be assigned + * @return False if the table key already exists with a different type + */ + public boolean putNumberArray(String key, double[] value) { + return table.putNumberArray(key, value); + } + + /** + * Put a number array in the table. + * @param key the key to be assigned to + * @param value the value that will be assigned + * @return False if the table key already exists with a different type + */ + public boolean putNumberArray(String key, Double[] value) { + return table.putNumberArray(key, value); + } + + /** + * Gets the current value in the table, setting it if it does not exist. + * @param key the key + * @param defaultValue the default value to set if key doens't exist. + * @return False if the table key exists with a different type + */ + public boolean setDefaultNumberArray(String key, double[] defaultValue) { + return table.setDefaultNumberArray(key, defaultValue); + } + + /** + * Gets the current value in the table, setting it if it does not exist. + * @param key the key + * @param defaultValue the default value to set if key doens't exist. + * @return False if the table key exists with a different type + */ + public boolean setDefaultNumberArray(String key, Double[] defaultValue) { + return table.setDefaultNumberArray(key, defaultValue); + } + + /** + * Returns the number array the key maps to. + * @param key the key to look up + * @return the value associated with the given key + * @throws TableKeyNotDefinedException if there is no value associated with + * the given key + * @deprecated This exception-raising method has been replaced by the + * default-taking method {@link #getNumberArray(String, double[])}. + */ + @Deprecated + public double[] getNumberArray(String key) throws TableKeyNotDefinedException { + return table.getNumberArray(key); + } + + /** + * Returns the number array the key maps to. If the key does not exist or is + * of different type, it will return the default value. + * @param key the key to look up + * @param defaultValue the value to be returned if no value is found + * @return the value associated with the given key or the given default value + * if there is no value associated with the key + */ + public double[] getNumberArray(String key, double[] defaultValue) { + return table.getNumberArray(key, defaultValue); + } + + /** + * Returns the number array the key maps to. If the key does not exist or is + * of different type, it will return the default value. + * @param key the key to look up + * @param defaultValue the value to be returned if no value is found + * @return the value associated with the given key or the given default value + * if there is no value associated with the key + */ + public Double[] getNumberArray(String key, Double[] defaultValue) { + return table.getNumberArray(key, defaultValue); + } + + /** + * Put a string array in the table. + * @param key the key to be assigned to + * @param value the value that will be assigned + * @return False if the table key already exists with a different type + */ + public boolean putStringArray(String key, String[] value) { + return table.putStringArray(key, value); + } + + /** + * Gets the current value in the table, setting it if it does not exist. + * @param key the key + * @param defaultValue the default value to set if key doens't exist. + * @return False if the table key exists with a different type + */ + public boolean setDefaultStringArray(String key, String[] defaultValue) { + return table.setDefaultStringArray(key, defaultValue); + } + + /** + * Returns the string array the key maps to. + * @param key the key to look up + * @return the value associated with the given key + * @throws TableKeyNotDefinedException if there is no value associated with + * the given key + * @deprecated This exception-raising method has been replaced by the + * default-taking method {@link #getStringArray(String, String[])}. + */ + @Deprecated + public String[] getStringArray(String key) throws TableKeyNotDefinedException { + return table.getStringArray(key); + } + + /** + * Returns the string array the key maps to. If the key does not exist or is + * of different type, it will return the default value. + * @param key the key to look up + * @param defaultValue the value to be returned if no value is found + * @return the value associated with the given key or the given default value + * if there is no value associated with the key + */ + public String[] getStringArray(String key, String[] defaultValue) { + return table.getStringArray(key, defaultValue); + } + + /** + * Put a raw value (byte array) in the table. + * @param key the key to be assigned to + * @param value the value that will be assigned + * @return False if the table key already exists with a different type + */ + public boolean putRaw(String key, byte[] value) { + return table.putRaw(key, value); + } + + /** + * Put a raw value (bytes from a byte buffer) in the table. + * @param key the key to be assigned to + * @param value the value that will be assigned + * @param len the length of the value + * @return False if the table key already exists with a different type + */ + public boolean putRaw(String key, ByteBuffer value, int len) { + return table.putRaw(key, value, len); + } + + /** + * Gets the current value in the table, setting it if it does not exist. + * @param key the key + * @param defaultValue the default value to set if key doens't exist. + * @return False if the table key exists with a different type + */ + public boolean setDefaultRaw(String key, byte[] defaultValue) { + return table.setDefaultRaw(key, defaultValue); + } + + /** + * Returns the raw value (byte array) the key maps to. + * @param key the key to look up + * @return the value associated with the given key + * @throws TableKeyNotDefinedException if there is no value associated with + * the given key + * @deprecated This exception-raising method has been replaced by the + * default-taking method {@link #getRaw(String, byte[])}. + */ + @Deprecated + public byte[] getRaw(String key) throws TableKeyNotDefinedException { + return table.getRaw(key); + } + + /** + * Returns the raw value (byte array) the key maps to. If the key does not + * exist or is of different type, it will return the default value. + * @param key the key to look up + * @param defaultValue the value to be returned if no value is found + * @return the value associated with the given key or the given default value + * if there is no value associated with the key + */ + public byte[] getRaw(String key, byte[] defaultValue) { + return table.getRaw(key, defaultValue); + } /* * Deprecated Methods