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 newResultSetholding 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 booleancontains(Object code)Returnstrueif this collection contains the specified element.protected voidfinalize()Closes the underlying statements.booleanisEmpty()Returnstrueif this collection contains no elements.Iterator<String>iterator()Returns an iterator over the codes.intsize()Count the number of elements in the underlying result set.protected PreparedStatementvalidateStatement(PreparedStatement stmt, String sql)protected ObjectwriteReplace()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()
Returnstrueif this collection contains no elements. This method fetch at most one row instead of counting all rows.- Specified by:
isEmptyin interfaceCollection<String>- Specified by:
isEmptyin interfaceSet<String>- Overrides:
isEmptyin classAbstractCollection<String>
-
size
public int size()
Count the number of elements in the underlying result set.- Specified by:
sizein interfaceCollection<String>- Specified by:
sizein interfaceSet<String>- Specified by:
sizein classAbstractCollection<String>
-
contains
public boolean contains(Object code)
Returnstrueif this collection contains the specified element.- Specified by:
containsin interfaceCollection<String>- Specified by:
containsin interfaceSet<String>- Overrides:
containsin 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 SQLExceptionCloses 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:
finalizein classObject- Throws:
SQLException
-
-