Package org.gedcomx.util
Class DocMap
java.lang.Object
org.gedcomx.util.DocMap
Utility class for simplifying the lookup of Person, SourceDescription, RecordDescription or Agent objects
in a GedcomX document.
Each object can be looked up by its local 'id' (with or without a preceding "#"), using a String or URI.
Persons can also be looked up by any of their identifiers, and SourceDescriptions can be looked up by
any of the identifiers of the entity they are describing.
User: Randy Wilson
Date: 6/9/14
Time: 3:53 PM
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionFind the Agent with the given local id.Find the Agent with the given local id.getAgentMap(Gedcomx doc) Create a map of local id (and "#" + id) to the Agent that has that id.Get the Gedcomx document that was used to create this DocMap.Get the Person described by the main SourceDescription.Get the SourceDescription referenced by the GedcomX document's descriptionRef.Get the person from the GedcomX document that has the given id (with or without "#") or an identifier that matches the given idOrUrl.getPerson(ResourceReference resourceReference) Get the person from the GedcomX document that has the id given in the URI of the given ResourceReference.Get the person from the GedcomX document that has the given id (with or without "#") or identifier.getPersonMap(Gedcomx doc) Create a map of local id (and "#" + id) as well as all person identifiers to the local Person object with that id or identifier.getPlaceDescription(String idOrUri) Find the PlaceDescription with the given local id (or "#" + local id) or the given URI.getPlaceDescription(URI placeDescriptionUri) Find the PlaceDescription with the given local id (or "#" + local id) or the given URI.getPlaceDescription(PlaceReference placeReference) Find the PlaceDescription with the given PlaceReference.static Map<String,PlaceDescription> getPlaceMap(Gedcomx doc) Create a map of local id (and "#" + id) and identifier URIs to the PlaceDescription that has that id or URL.getRecordDescriptor(String recordDescriptorIdOrUrl) Find the RecordDescriptor referenced by the given id (with or without a "#"), or URL (with "#" and a local id).getRecordDescriptor(URI recordDescriptorId) Find the RecordDescriptor referenced by the given id (with or without a "#").static Map<String,RecordDescriptor> Create a map of local id (and "#" + id) to the RecordDescriptor that has that id.getSourceDescription(String idOrUrl) Get the SourceDescription from the GedcomX document that has the given id (with or without "#") or an identifier that matches the given idOrUrl.getSourceDescription(URI uri) Get the SourceDescription from the GedcomX document that has the given id (with or without "#") or an identifier that matches the given idOrUrl.getSourceDescription(SourceReference sourceReference) Get the SourceDescription referenced by the given SourceReference.static Map<String,SourceDescription> Create a map of id (and "#" + id) and all identifier URI strings to SourceDescription with that ID, to make it easier to look up SourceDescriptions that are referenced elsewhere.voidUpdate the maps with the given GedcomX document (e.g., when the document has changed).
-
Constructor Details
-
DocMap
Constructor. Create an object that allows convenient lookup of things in a GedcomX document.- Parameters:
doc- - GedcomX document to build maps for.
-
-
Method Details
-
update
Update the maps with the given GedcomX document (e.g., when the document has changed).- Parameters:
doc- - GedcomX document to rebuild maps for.
-
getDocument
Get the Gedcomx document that was used to create this DocMap.- Returns:
- GedcomX document that was used to create this DocMap.
-
getMainSourceDescription
Get the SourceDescription referenced by the GedcomX document's descriptionRef.- Returns:
- SourceDescription referenced by the GedcomX document's descriptionRef, or null if none.
-
getMainPerson
Get the Person described by the main SourceDescription. Returns null if there is no main SourceDescription or if this document's main thing is not a Person.- Returns:
- Person referenced by the main SourceDescription.
-
getPerson
Get the person from the GedcomX document that has the given id (with or without "#") or an identifier that matches the given idOrUrl. Can look a person up by "p1", "#p1" or "http://whatever.com/persons/12345".- Parameters:
idOrUrl- - local person id (with or without "#") or any person identifier- Returns:
- Person with the given id or identifier.
-
getPerson
Get the person from the GedcomX document that has the given id (with or without "#") or identifier. Can look a person up by "p1", "#p1" or "http://whatever.com/persons/12345".- Parameters:
uri- - local person id (with or without "#") or any person identifier- Returns:
- Person with the given id or identifier.
-
getPerson
Get the person from the GedcomX document that has the id given in the URI of the given ResourceReference. Can look a person up by "p1", "#p1" or "http://whatever.com/persons/12345".- Parameters:
resourceReference- - local person id (with or without "#") or any person identifier- Returns:
- Person with the given id or identifier.
-
getSourceDescription
Get the SourceDescription from the GedcomX document that has the given id (with or without "#") or an identifier that matches the given idOrUrl. Can look a source description up by "sd1", "#sd1" or "http://whatever.com/records/12345", if that is an identifier that the source description is describing and has listed as one of the identifiers.- Parameters:
idOrUrl- - local person id (with or without "#") or any person identifier- Returns:
- Person with the given id or identifier.
-
getSourceDescription
Get the SourceDescription from the GedcomX document that has the given id (with or without "#") or an identifier that matches the given idOrUrl. Can look a source description up by "sd1", "#sd1" or "http://whatever.com/records/12345", if that is an identifier that the source description is describing and has listed as one of the identifiers.- Parameters:
uri- - local source description id (with or without "#") or any identifier in the source description.- Returns:
- Person with the given id or identifier.
-
getSourceDescription
Get the SourceDescription referenced by the given SourceReference. Typically the SourceReference will reference the SourceDescription by "#" + its local id.- Parameters:
sourceReference- - SourceReference that points to a SourceDescription.- Returns:
- SourceDescription referenced by the given SourceReference.
-
getRecordDescriptor
Find the RecordDescriptor referenced by the given id (with or without a "#"), or URL (with "#" and a local id).- Parameters:
recordDescriptorIdOrUrl- - local id of a RecordDescriptor (with or without a "#"), or URL of recordDescriptor (with "#" + local id at end).- Returns:
- RecordDescriptor referenced by the given id or URL.
-
getRecordDescriptor
Find the RecordDescriptor referenced by the given id (with or without a "#").- Parameters:
recordDescriptorId- - URI containing the local id of a RecordDescriptor (with or without a "#").- Returns:
- RecordDescriptor referenced by the given id.
-
getAgent
Find the Agent with the given local id.- Parameters:
agentId- - id of an agent (with or without an initial "#").- Returns:
- Agent with the given id.
-
getAgent
Find the Agent with the given local id.- Parameters:
agentId- - URI containing the id of an agent (with or without an initial "#").- Returns:
- Agent with the given id.
-
getPlaceDescription
Find the PlaceDescription with the given local id (or "#" + local id) or the given URI.- Parameters:
idOrUri- - local id (with or without "#") or full identifier URI of a PlaceDescription.- Returns:
- PlaceDescription object with the given local id or URI.
-
getPlaceDescription
Find the PlaceDescription with the given local id (or "#" + local id) or the given URI.- Parameters:
placeDescriptionUri- - local id (with or without "#") or full identifier URI of a PlaceDescription.- Returns:
- PlaceDescription object with the given local id or URI.
-
getPlaceDescription
Find the PlaceDescription with the given PlaceReference.- Parameters:
placeReference- - PlaceReference that contains the (probably local) id of a PlaceDescription.- Returns:
- PlaceDescription object with the given local id or URI.
-
getSourceDescriptionMap
Create a map of id (and "#" + id) and all identifier URI strings to SourceDescription with that ID, to make it easier to look up SourceDescriptions that are referenced elsewhere.- Parameters:
doc- - GedcomX document to create a map for.- Returns:
- map of id (and "#" + id) to SourceDescription.
-
getPersonMap
Create a map of local id (and "#" + id) as well as all person identifiers to the local Person object with that id or identifier.- Parameters:
doc- - GedcomX document to create a map for.- Returns:
- map of local id, "#" + id, and all URIs for each Person in the document to that Person.
-
getAgentMap
Create a map of local id (and "#" + id) to the Agent that has that id. If there are no agents, an empty (but non-null) map is returned.- Parameters:
doc- - document to find agents for- Returns:
- Map of local id (and "#" + id) to each Agent in the doc.
-
getRecordDescriptorMap
Create a map of local id (and "#" + id) to the RecordDescriptor that has that id. If there are no record descriptors, an empty (but non-null) map is returned.- Parameters:
doc- - document to find record descriptors for- Returns:
- Map of local id (and "#" + id) to each RecordDescriptor in the doc.
-
getPlaceMap
Create a map of local id (and "#" + id) and identifier URIs to the PlaceDescription that has that id or URL. If there are no place descriptions, an empty (but non-null) map is returned.- Parameters:
doc- - document to find place descriptions for- Returns:
- Map of local id (and "#" + id) and URI string to each PlaceDescription in the doc.
-