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

pack-priv final Class LocalSymbolTableImports

extends Object
Class Inheritance
Static Imports
com.amazon.ion.SymbolTable.UNKNOWN_SYMBOL_ID

This class manages the system symbol table and any shared symbol table(s) imported by a local symbol table. It provides "find" methods to find either symbol Ids or names in the imported tables.

This class is immutable, and hence safe for use by multiple threads.

Field Summary

Modifier and TypeField and Description
private final int[]
myBaseSids

The base Sid of each symtab in myImports in parallel, i.e., myBaseSids[0] references myImports[0].

private final SymbolTable[]
myImports

The symtabs imported by a local symtab, never null or empty.

private final int
myMaxId

The maxId of all imported tables, i.e., the sum of all maxIds declared by symtabs in myImports.

Constructor Summary

AccessConstructor and Description
pack-priv
LocalSymbolTableImports(List<SymbolTable>
the imported symtabs, must contain at least one element; the first element must be a system symtab, the rest must be non-system shared symtabs
importTables
)

Constructor, takes the passed-in importTables containing the imported symtabs.

pack-priv
LocalSymbolTableImports(SymbolTable
the default system symtab, which will be used if the first import in imports isn't a system symtab, never null
defaultSystemSymtab
,
SymbolTable...
the set of shared symbol tables to import; the first (and only the first) may be a system table, in which case the defaultSystemSymtab is ignored
imports
)

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
equalImports(LocalSymbolTableImports other)

Determines whether the passed-in instance has the same sequence of symbol table imports as this instance.

pack-priv SymbolToken

Returns:

the interned symbol (with both text and SID), or null if it's not defined by an imported table
find
(String
the symbol text to find
text
)

Finds a symbol already interned by an import, returning the lowest known SID.

pack-priv String
findKnownSymbol(int sid)

pack-priv int
pack-priv SymbolTable[]

Returns:

a newly allocated copy of the imported symtabs
getImportedTables
()

Gets all non-system shared symtabs (if any).

pack-priv SymbolTable[]

Returns:

the backing array of imported symtabs, as-is; the first element is a system symtab, the rest are non-system shared symtabs
getImportedTablesNoCopy
()

Returns the myImports member field without making a copy.

pack-priv int
pack-priv SymbolTable
getSystemSymbolTable()

Gets the sole system symtab.

private static int

Returns:

the sum of all imports' maxIds
prepBaseSids
(int[] baseSids, SymbolTable[] imports)

Collects the necessary maxId info.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

myBaseSidsback to summary
private final int[] myBaseSids

The base Sid of each symtab in myImports in parallel, i.e., myBaseSids[0] references myImports[0]. Must be the same length as myImports.

myImportsback to summary
private final SymbolTable[] myImports

The symtabs imported by a local symtab, never null or empty. The first symtab must be a system symtab, the rest must be non-system shared symtabs.

myMaxIdback to summary
private final int myMaxId

The maxId of all imported tables, i.e., the sum of all maxIds declared by symtabs in myImports.

Constructor Detail

LocalSymbolTableImportsback to summary
pack-priv LocalSymbolTableImports(List<SymbolTable> importTables)

Constructor, takes the passed-in importTables containing the imported symtabs.

Parameters
importTables:List<SymbolTable>

the imported symtabs, must contain at least one element; the first element must be a system symtab, the rest must be non-system shared symtabs

Exceptions
IllegalArgumentException:
if any import is a local table, or if any but the first is a system table
NullPointerException:
if any import is null
LocalSymbolTableImportsback to summary
pack-priv LocalSymbolTableImports(SymbolTable defaultSystemSymtab, SymbolTable... imports)
Parameters
defaultSystemSymtab:SymbolTable

the default system symtab, which will be used if the first import in imports isn't a system symtab, never null

imports:SymbolTable[]

the set of shared symbol tables to import; the first (and only the first) may be a system table, in which case the defaultSystemSymtab is ignored

Exceptions
IllegalArgumentException:
if any import is a local table, or if any but the first is a system table
NullPointerException:
if any import is null

Method Detail

equalImportsback to summary
pack-priv boolean equalImports(LocalSymbolTableImports other)

Determines whether the passed-in instance has the same sequence of symbol table imports as this instance. Note that equality of these imports are checked using their reference, instead of their semantic state.

findback to summary
pack-priv SymbolToken find(String text)

Finds a symbol already interned by an import, returning the lowest known SID.

This method will not necessarily return the same instance given the same input.

Parameters
text:String

the symbol text to find

Returns:SymbolToken

the interned symbol (with both text and SID), or null if it's not defined by an imported table

findKnownSymbolback to summary
pack-priv String findKnownSymbol(int sid)
findSymbolback to summary
pack-priv int findSymbol(String name)
getImportedTablesback to summary
pack-priv SymbolTable[] getImportedTables()

Gets all non-system shared symtabs (if any).

Returns:SymbolTable[]

a newly allocated copy of the imported symtabs

getImportedTablesNoCopyback to summary
pack-priv SymbolTable[] getImportedTablesNoCopy()

Returns the myImports member field without making a copy.

Note

Callers must not modify the resulting SymbolTable array! This will violate the immutability property of this class.

Returns:SymbolTable[]

the backing array of imported symtabs, as-is; the first element is a system symtab, the rest are non-system shared symtabs

See Also
getImportedTables()
getMaxIdback to summary
pack-priv int getMaxId()
getSystemSymbolTableback to summary
pack-priv SymbolTable getSystemSymbolTable()

Gets the sole system symtab.

prepBaseSidsback to summary
private static int prepBaseSids(int[] baseSids, SymbolTable[] imports)

Collects the necessary maxId info. from the passed-in imports and populates the baseSids array.

Returns:int

the sum of all imports' maxIds

Exceptions
IllegalArgumentException:
if any symtab beyond the first is a local or system symtab
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override