Package com.amazon.ion.system
Class SimpleCatalog
- java.lang.Object
-
- com.amazon.ion.system.SimpleCatalog
-
- All Implemented Interfaces:
IonCatalog
,IonMutableCatalog
,java.lang.Iterable<SymbolTable>
public class SimpleCatalog extends java.lang.Object implements IonMutableCatalog, java.lang.Iterable<SymbolTable>
A basic implementation ofIonCatalog
as a hash table. There is no automatic removal of entries.
-
-
Constructor Summary
Constructors Constructor Description SimpleCatalog()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SymbolTable
getTable(java.lang.String name)
Gets a symbol table with a specific name and the highest version possible.SymbolTable
getTable(java.lang.String name, int version)
Gets a desired symbol table from this catalog, using an exact match if possible.java.util.Iterator<SymbolTable>
iterator()
Constructs an iterator that enumerates all of the shared symbol tables in this catalog, at the time of method invocation.void
putTable(SymbolTable table)
Adds a symbol table to this catalog.SymbolTable
removeTable(java.lang.String name, int version)
Removes a symbol table from this catalog.
-
-
-
Method Detail
-
getTable
public SymbolTable getTable(java.lang.String name)
Description copied from interface:IonCatalog
Gets a symbol table with a specific name and the highest version possible.- Specified by:
getTable
in interfaceIonCatalog
- Parameters:
name
- identifies the desired symbol table.- Returns:
- a shared symbol table with the given name, or
null
if this catalog has no table with the name.
-
getTable
public SymbolTable getTable(java.lang.String name, int version)
Description copied from interface:IonCatalog
Gets a desired symbol table from this catalog, using an exact match if possible.Implentations must make a best effort to find an exact match. If an exact match cannot be found, then this method must make a best effort to find the best match available.
- Specified by:
getTable
in interfaceIonCatalog
- Returns:
- the shared symbol table with the given name and version, when an
exact match is possible. Otherwise, returns the lowest possible version
larger than requested. Otherwise, return the largest possible version
lower than requested. If no table with the name can be found, then
this method returns
null
.
-
putTable
public void putTable(SymbolTable table)
Description copied from interface:IonMutableCatalog
Adds a symbol table to this catalog. This interface does not define the behavior of this method if this catalog already contains a table with the same name and version.- Specified by:
putTable
in interfaceIonMutableCatalog
- Parameters:
table
- must be shared but not a system table or substitute table.
-
removeTable
public SymbolTable removeTable(java.lang.String name, int version)
Removes a symbol table from this catalog.- Returns:
- the removed table, or
null
if this catalog has no matching table.
-
iterator
public java.util.Iterator<SymbolTable> iterator()
Constructs an iterator that enumerates all of the shared symbol tables in this catalog, at the time of method invocation. The result represents a snapshot of the state of this catalog.- Specified by:
iterator
in interfacejava.lang.Iterable<SymbolTable>
- Returns:
- a non-null, but potentially empty, iterator.
-
-