Package org.openstreetmap.josm.data.gpx
Class GpxExtensionCollection
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<GpxExtension>
-
- org.openstreetmap.josm.data.gpx.GpxExtensionCollection
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<GpxExtension>
,Collection<GpxExtension>
,List<GpxExtension>
,RandomAccess
public class GpxExtensionCollection extends ArrayList<GpxExtension>
Class extendingArrayList<GpxExtension>
. Can be used to collectGpxExtension
s while reading GPX files, seeGpxReader
- Since:
- 15496
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private Stack<GpxExtension>
childStack
private IWithAttributes
parent
private static long
serialVersionUID
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description GpxExtensionCollection()
Constructs a newGpxExtensionCollection
GpxExtensionCollection(IWithAttributes parent)
Constructs a newGpxExtensionCollection
with the given parent
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GpxExtension
add(String prefix, String key)
Creates and adds a newGpxExtension
from the given parameters.GpxExtension
add(String prefix, String key, String value)
Creates and adds a newGpxExtension
from the given parameters.boolean
add(GpxExtension gpx)
boolean
addAll(Collection<? extends GpxExtension> extensions)
void
addFlat(String[] chain, String value)
Adds an extension from a flat chain without prefix, e.g.GpxExtension
addIfNotPresent(String prefix, String key)
Creates and adds a newGpxExtension
, if it hasn't been added yet.GpxExtension
addOrUpdate(String prefix, String key, String value)
Creates and adds a newGpxExtension
or updates its value and shows it if already present.void
clear()
void
closeChild(String qName, String value)
Sets the value for the last child and pops it from the stack, so the next one will be added to its parent.GpxExtension
find(String prefix, String key)
Searches recursively for the extension with the given prefix and key in all childrenvoid
findAndRemove(String prefix, String key)
Searches and removes recursively all extensions with the given prefix and key in all childrenGpxExtension
get(String prefix, String key)
Gets the extension with the given prefix and keyGpxExtensionCollection
getAll(String prefix, String key)
Gets all extensions with the given prefix and keyStream<String>
getPrefixesStream()
Gets all prefixes of direct (writable) childrenboolean
isVisible()
Determines if this collection contains writable extensions.void
openChild(String namespaceURI, String qName, Attributes atts)
Adds a child extension to the last extension and pushes it to the stack.void
remove(String prefix, String key)
Removes allGpxExtension
s with the given prefix and key in direct childrenvoid
removeAllWithPrefix(String prefix)
Removes all extensions with the given prefix in direct childrenStream<GpxExtension>
stream(String prefix, String key)
Gets a stream with all extensions with the given prefix and key-
Methods inherited from class java.util.ArrayList
add, addAll, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
Methods inherited from class java.util.AbstractCollection
containsAll, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Methods inherited from interface java.util.List
containsAll
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
childStack
private Stack<GpxExtension> childStack
-
parent
private IWithAttributes parent
-
-
Constructor Detail
-
GpxExtensionCollection
public GpxExtensionCollection()
Constructs a newGpxExtensionCollection
-
GpxExtensionCollection
public GpxExtensionCollection(IWithAttributes parent)
Constructs a newGpxExtensionCollection
with the given parent- Parameters:
parent
- the parent extendingIWithAttributes
-
-
Method Detail
-
openChild
public void openChild(String namespaceURI, String qName, Attributes atts)
Adds a child extension to the last extension and pushes it to the stack.- Parameters:
namespaceURI
- the URI of the XML namespace, used to determine supported extensions (josm, gpxx, gpxd) regardless of the prefix.qName
- the qualified name of the XML element including prefixatts
- the attributes
-
closeChild
public void closeChild(String qName, String value)
Sets the value for the last child and pops it from the stack, so the next one will be added to its parent. A warning is issued if the qualified name does not equal the currently opened child.- Parameters:
qName
- the qualified namevalue
- the value
-
add
public boolean add(GpxExtension gpx)
- Specified by:
add
in interfaceCollection<GpxExtension>
- Specified by:
add
in interfaceList<GpxExtension>
- Overrides:
add
in classArrayList<GpxExtension>
-
add
public GpxExtension add(String prefix, String key)
Creates and adds a newGpxExtension
from the given parameters.- Parameters:
prefix
- the prefixkey
- the key/tag- Returns:
- the added GpxExtension
-
add
public GpxExtension add(String prefix, String key, String value)
Creates and adds a newGpxExtension
from the given parameters.- Parameters:
prefix
- the prefixkey
- the key/tagvalue
- the value, can benull
- Returns:
- the added GpxExtension
-
addIfNotPresent
public GpxExtension addIfNotPresent(String prefix, String key)
Creates and adds a newGpxExtension
, if it hasn't been added yet. Shows it if it has.- Parameters:
prefix
- the prefixkey
- the key/tag- Returns:
- the added or found GpxExtension
- See Also:
GpxExtension.show()
-
addOrUpdate
public GpxExtension addOrUpdate(String prefix, String key, String value)
Creates and adds a newGpxExtension
or updates its value and shows it if already present.- Parameters:
prefix
- the prefixkey
- the key/tagvalue
- the value- Returns:
- the added or found GpxExtension
- See Also:
GpxExtension.show()
-
addAll
public boolean addAll(Collection<? extends GpxExtension> extensions)
- Specified by:
addAll
in interfaceCollection<GpxExtension>
- Specified by:
addAll
in interfaceList<GpxExtension>
- Overrides:
addAll
in classArrayList<GpxExtension>
-
addFlat
public void addFlat(String[] chain, String value)
Adds an extension from a flat chain without prefix, e.g. when converting from OSM- Parameters:
chain
- the full key chain, e.g. ["extension", "gpxx", "TrackExtension", "DisplayColor"]value
- the value
-
get
public GpxExtension get(String prefix, String key)
Gets the extension with the given prefix and key- Parameters:
prefix
- the prefixkey
- the key/tag- Returns:
- the
GpxExtension
if found ornull
-
getAll
public GpxExtensionCollection getAll(String prefix, String key)
Gets all extensions with the given prefix and key- Parameters:
prefix
- the prefixkey
- the key/tag- Returns:
- a
GpxExtensionCollection
with the extensions, empty collection if none found
-
stream
public Stream<GpxExtension> stream(String prefix, String key)
Gets a stream with all extensions with the given prefix and key- Parameters:
prefix
- the prefixkey
- the key/tag- Returns:
- the
Stream<
GpxExtension
>
-
find
public GpxExtension find(String prefix, String key)
Searches recursively for the extension with the given prefix and key in all children- Parameters:
prefix
- the prefix to look forkey
- the key to look for- Returns:
- the extension if found, otherwise
null
-
findAndRemove
public void findAndRemove(String prefix, String key)
Searches and removes recursively all extensions with the given prefix and key in all children- Parameters:
prefix
- the prefix to look forkey
- the key to look for
-
remove
public void remove(String prefix, String key)
Removes allGpxExtension
s with the given prefix and key in direct children- Parameters:
prefix
- the prefixkey
- the key/tag
-
removeAllWithPrefix
public void removeAllWithPrefix(String prefix)
Removes all extensions with the given prefix in direct children- Parameters:
prefix
- the prefix
-
getPrefixesStream
public Stream<String> getPrefixesStream()
Gets all prefixes of direct (writable) children- Returns:
- stream with the prefixes
-
isVisible
public boolean isVisible()
Determines if this collection contains writable extensions.- Returns:
true
if this collection contains writable extensions
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<GpxExtension>
- Specified by:
clear
in interfaceList<GpxExtension>
- Overrides:
clear
in classArrayList<GpxExtension>
-
-