Class AuthorityCodes
- Object
-
- AbstractCollection<E>
-
- AbstractSet<String>
-
- AuthorityCodes
-
- All Implemented Interfaces:
Serializable
,Iterable<String>
,Collection<String>
,Set<String>
public final class AuthorityCodes extends AbstractSet<String> implements Serializable
A set of EPSG authority codes. This set requires a living connection to the EPSG database. Alliterator()
method call creates a newResultSet
holding the codes. However, call tocontains(java.lang.Object)
map directly to a SQL call.Serialization of this class store a copy of all authority codes. The serialization do not preserve any connection to the database.
- Since:
- 2.2
- Author:
- Martin Desruisseaux (IRD)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AuthorityCodes(TableInfo table, Class<?> type, DirectEpsgFactory factory)
Creates a new set of authority codes for the specified type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(Object code)
Returnstrue
if this collection contains the specified element.protected void
finalize()
Closes the underlying statements.boolean
isEmpty()
Returnstrue
if this collection contains no elements.Iterator<String>
iterator()
Returns an iterator over the codes.int
size()
Count the number of elements in the underlying result set.protected PreparedStatement
validateStatement(PreparedStatement stmt, String sql)
protected Object
writeReplace()
Returns a serializable copy of this set.-
Methods inherited from class AbstractSet
equals, hashCode, removeAll
-
Methods inherited from class AbstractCollection
add, addAll, clear, containsAll, remove, retainAll, toArray, toArray, toString
-
Methods inherited from interface Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface Set
add, addAll, clear, containsAll, remove, retainAll, spliterator, toArray, toArray
-
-
-
-
Field Detail
-
type
public final Class<?> type
The type for this code set. This is translated to the most appropriate interface type even if the user supplied an implementation type.
-
-
Constructor Detail
-
AuthorityCodes
public AuthorityCodes(TableInfo table, Class<?> type, DirectEpsgFactory factory)
Creates a new set of authority codes for the specified type.- Parameters:
table
- The table to query.type
- The type to query.factory
- The factory originator.
-
-
Method Detail
-
validateStatement
protected PreparedStatement validateStatement(PreparedStatement stmt, String sql) throws SQLException
- Throws:
SQLException
-
isEmpty
public boolean isEmpty()
Returnstrue
if this collection contains no elements. This method fetch at most one row instead of counting all rows.- Specified by:
isEmpty
in interfaceCollection<String>
- Specified by:
isEmpty
in interfaceSet<String>
- Overrides:
isEmpty
in classAbstractCollection<String>
-
size
public int size()
Count the number of elements in the underlying result set.- Specified by:
size
in interfaceCollection<String>
- Specified by:
size
in interfaceSet<String>
- Specified by:
size
in classAbstractCollection<String>
-
contains
public boolean contains(Object code)
Returnstrue
if this collection contains the specified element.- Specified by:
contains
in interfaceCollection<String>
- Specified by:
contains
in interfaceSet<String>
- Overrides:
contains
in classAbstractCollection<String>
-
iterator
public Iterator<String> iterator()
Returns an iterator over the codes. The iterator is backed by a livingResultSet
, which will be closed as soon as the iterator reach the last element.
-
writeReplace
protected Object writeReplace() throws ObjectStreamException
Returns a serializable copy of this set. This method is invoked automatically during serialization. The serialised set of authority code is disconnected from the underlying database.- Throws:
ObjectStreamException
-
finalize
protected void finalize() throws SQLException
Closes the underlying statements. Note: this method is also invoked directly byDirectEpsgFactory.dispose()
, which is okay in this particular case since the implementation of this method can be executed an arbitrary amount of times.- Overrides:
finalize
in classObject
- Throws:
SQLException
-
-