Top Description Fields Constructors Methods
com.amazon.ion.system

public Class SimpleCatalog

extends Object
implements IonMutableCatalog, Iterable<SymbolTable>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable, com.amazon.ion.IonMutableCatalog, com.amazon.ion.IonCatalog
Imports
com.amazon.ion.IonCatalog, .IonMutableCatalog, .SymbolTable, java.util.ArrayList, .Collection, .HashMap, .Iterator, .Map, .TreeMap

A basic implementation of IonCatalog as a hash table. There is no automatic removal of entries.

Field Summary

Modifier and TypeField and Description
private Map<String, TreeMap<Integer, SymbolTable>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv static Integer
bestMatch(int requestedVersion, Iterable<Integer> availableVersions)

public SymbolTable
getTable(String
identifies the desired symbol table.
name
)

Implements com.amazon.ion.IonCatalog.getTable.

Gets a symbol table with a specific name and the highest version possible.

public SymbolTable
getTable(String name, int version)

Implements com.amazon.ion.IonCatalog.getTable.

Gets a desired symbol table from this catalog, using an exact match if possible.

public Iterator<SymbolTable>

Returns:

a non-null, but potentially empty, iterator.
iterator
()

Implements java.lang.Iterable.iterator.

Constructs an iterator that enumerates all of the shared symbol tables in this catalog, at the time of method invocation.

public void
putTable(SymbolTable
must be shared but not a system table or substitute table.
table
)

Implements com.amazon.ion.IonMutableCatalog.putTable.

Adds a symbol table to this catalog.

public SymbolTable

Returns:

the removed table, or null if this catalog has no matching table.
removeTable
(String name, int version)

Removes a symbol table from this catalog.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

myTablesByNameback to summary
private Map<String, TreeMap<Integer, SymbolTable>> myTablesByName

Constructor Detail

SimpleCatalogback to summary
public SimpleCatalog()

Method Detail

bestMatchback to summary
pack-priv static Integer bestMatch(int requestedVersion, Iterable<Integer> availableVersions)
getTableback to summary
public SymbolTable getTable(String name)

Implements com.amazon.ion.IonCatalog.getTable.

Doc from com.amazon.ion.IonCatalog.getTable.

Gets a symbol table with a specific name and the highest version possible.

Parameters
name:String

identifies the desired symbol table.

Returns:SymbolTable

a shared symbol table with the given name, or null if this catalog has no table with the name.

getTableback to summary
public SymbolTable getTable(String name, int version)

Implements com.amazon.ion.IonCatalog.getTable.

Doc from com.amazon.ion.IonCatalog.getTable.

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.

Returns:SymbolTable

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.

iteratorback to summary
public Iterator<SymbolTable> iterator()

Implements java.lang.Iterable.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.

Returns:Iterator<SymbolTable>

a non-null, but potentially empty, iterator.

putTableback to summary
public void putTable(SymbolTable table)

Implements com.amazon.ion.IonMutableCatalog.putTable.

Doc from com.amazon.ion.IonMutableCatalog.putTable.

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.

Parameters
table:SymbolTable

must be shared but not a system table or substitute table.

removeTableback to summary
public SymbolTable removeTable(String name, int version)

Removes a symbol table from this catalog.

Returns:SymbolTable

the removed table, or null if this catalog has no matching table.