Package gov.usgs.earthquake.distribution
Class QuakemlProductCreator
java.lang.Object
gov.usgs.earthquake.distribution.QuakemlProductCreator
- All Implemented Interfaces:
ProductCreator
Create Products from ANSS Quakeml files.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault ConstructorQuakemlProductCreator
(boolean padForBase64Bug) Constructor taking in argument for Base64 bug padding -
Method Summary
Modifier and TypeMethodDescriptionfixRawQuakeml
(String rawMessage) Fixes base 64 bug: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8222187protected Content
gov.usgs.earthquake.quakeml.FileToQuakemlConverter
getEventProducts
(org.quakeml_1_2.Quakeml message, org.quakeml_1_2.Event event) Get products in quakeml event element.protected Product
getFocalMechanismProduct
(org.quakeml_1_2.Quakeml quakeml, org.quakeml_1_2.Event event, org.quakeml_1_2.FocalMechanism mech, String quakemlContent) getInternalEventProducts
(org.quakeml_1_2.Quakeml message, org.quakeml_1_2.InternalEvent event) Get internal products in quakeml event element.getProducts
(File file) Implement the ProductCreator interface.getQuakemlProducts
(String message) Gets Quakeml products with the message as a rawQuakemlgetQuakemlProducts
(org.quakeml_1_2.Quakeml message) Gets Quakeml products with no rawQuakemlgetQuakemlProducts
(org.quakeml_1_2.Quakeml message, String rawQuakeml) Get products in a quakeml message.getScenarioEventProducts
(org.quakeml_1_2.Quakeml message, org.quakeml_1_2.ScenarioEvent event) Get scenario products in quakeml event element.boolean
boolean
boolean
boolean
static void
Convert quakeml files to products.void
setConverter
(gov.usgs.earthquake.quakeml.FileToQuakemlConverter converter) void
setPadForBase64Bug
(boolean padForBase64Bug) void
setProperty taking in Integersvoid
setProperty for stringsvoid
setProperty
(Map<String, String> properties, String name, BigDecimal value) setProperty taking in BigDecimals.void
setProperty
(Map<String, String> properties, String name, BigDecimal value, boolean allowExponential) setProperty taking in BigDecimalsvoid
setProperty
(Map<String, String> properties, String name, BigInteger value) setProperty taking in BigIntegers.void
setProperty
(Map<String, String> properties, String name, org.quakeml_1_2.RealQuantity value) setProperty for RealQuantity values.void
setProperty
(Map<String, String> properties, String name, org.quakeml_1_2.RealQuantity value, boolean allowExponential) setProperty for RealQuantity valuesvoid
setProperty
(Map<String, String> properties, String name, org.quakeml_1_2.TimeQuantity value) setProperty for TimeQuantitiesvoid
setSendMechanismWhenPhasesExist
(boolean sendMechanismWhenPhasesExist) Enable sending mechanism when phases existvoid
setSendOriginWhenPhasesExist
(boolean sendOriginWhenPhasesExist) Enable sending origin when phases existvoid
setValidate
(boolean validate) Enable validation during getProducts method.
-
Field Details
-
LOGGER
For use in logging issues -
XML_CONTENT_TYPE
Content type for xml- See Also:
-
QUAKEML_CONTENT_PATH
Content path for quakeml- See Also:
-
CONTENTS_XML_PATH
Contents XML path- See Also:
-
METERS_PER_KILOMETER
Var for number of meters/kilometer... -
VERSION
Version- See Also:
-
-
Constructor Details
-
QuakemlProductCreator
public QuakemlProductCreator()Default Constructor -
QuakemlProductCreator
public QuakemlProductCreator(boolean padForBase64Bug) Constructor taking in argument for Base64 bug padding- Parameters:
padForBase64Bug
- Boolean if needed to pad
-
-
Method Details
-
getQuakemlProducts
Gets Quakeml products with no rawQuakeml- Parameters:
message
- Parsed quakeml message- Returns:
- List of products
- Throws:
Exception
- if error occurs
-
getQuakemlProducts
Gets Quakeml products with the message as a rawQuakeml- Parameters:
message
- Parsed quakeml message- Returns:
- List of products
- Throws:
Exception
- if error occurs
-
getQuakemlProducts
public List<Product> getQuakemlProducts(org.quakeml_1_2.Quakeml message, String rawQuakeml) throws Exception Get products in a quakeml message.- Parameters:
message
- the parsed quakeml message.rawQuakeml
- bytes of quakeml message. If null, the quakeml object will be serialized into xml. This parameter is used to preserve the original input, instead of always serializing from the quakeml object.- Returns:
- list of products generated from quakeml message.
- Throws:
Exception
- if error occurs
-
getInternalEventProducts
public List<Product> getInternalEventProducts(org.quakeml_1_2.Quakeml message, org.quakeml_1_2.InternalEvent event) throws Exception Get internal products in quakeml event element. CallsgetEventProducts(Quakeml, Event)
, and adds "internal-" prefix to each type in the returned list of products.- Parameters:
message
- the quakeml message.event
- the internal event element.- Returns:
- list of internal products found in event element, may be empty.
- Throws:
Exception
- if error occurs
-
getScenarioEventProducts
public List<Product> getScenarioEventProducts(org.quakeml_1_2.Quakeml message, org.quakeml_1_2.ScenarioEvent event) throws Exception Get scenario products in quakeml event element. CallsgetEventProducts(Quakeml, Event)
, and adds "-scenario" suffix to each type in the returned list of products.- Parameters:
message
- the quakeml message.event
- the scenario event element.- Returns:
- list of scenario products found in event element, may be empty.
- Throws:
Exception
- if error occurs
-
getEventProducts
public List<Product> getEventProducts(org.quakeml_1_2.Quakeml message, org.quakeml_1_2.Event event) throws Exception Get products in quakeml event element.- Parameters:
message
- the quakeml message.event
- the event element in the quakeml message.- Returns:
- list of products found in event element, may be empty.
- Throws:
Exception
- if error occurs
-
getFocalMechanismProduct
protected Product getFocalMechanismProduct(org.quakeml_1_2.Quakeml quakeml, org.quakeml_1_2.Event event, org.quakeml_1_2.FocalMechanism mech, String quakemlContent) - Parameters:
quakeml
- Quakemlevent
- the event element in the quakeml messagemech
- A focal mechanismquakemlContent
- String of content in Quakeml- Returns:
- A product derived from a focal mechanism
-
setProperty
public void setProperty(Map<String, String> properties, String name, org.quakeml_1_2.RealQuantity value) setProperty for RealQuantity values. No exponentials- Parameters:
properties
- to addname
- of propertyvalue
- of property
-
setProperty
public void setProperty(Map<String, String> properties, String name, org.quakeml_1_2.RealQuantity value, boolean allowExponential) setProperty for RealQuantity values- Parameters:
properties
- to addname
- of propertyvalue
- of propertyallowExponential
- if allowed
-
setProperty
setProperty for strings- Parameters:
properties
- to addname
- of propertyvalue
- of property
-
setProperty
public void setProperty(Map<String, String> properties, String name, org.quakeml_1_2.TimeQuantity value) setProperty for TimeQuantities- Parameters:
properties
- to addname
- of propertyvalue
- of property
-
setProperty
setProperty taking in BigDecimals. No exponentials- Parameters:
properties
- to addname
- of propertyvalue
- of property
-
setProperty
public void setProperty(Map<String, String> properties, String name, BigDecimal value, boolean allowExponential) setProperty taking in BigDecimals- Parameters:
properties
- to addname
- of propertyvalue
- of propertyallowExponential
- boolean
-
setProperty
setProperty taking in BigIntegers. No exponentials- Parameters:
properties
- to addname
- of propertyvalue
- of property
-
setProperty
setProperty taking in Integers- Parameters:
properties
- to addname
- of propertyvalue
- of property
-
setConverter
public void setConverter(gov.usgs.earthquake.quakeml.FileToQuakemlConverter converter) - Parameters:
converter
- FileToQuakeml Converter to set
-
getConverter
public gov.usgs.earthquake.quakeml.FileToQuakemlConverter getConverter()- Returns:
- FileToQuakeml converter
-
isValidate
public boolean isValidate()- Specified by:
isValidate
in interfaceProductCreator
- Returns:
- whether product creator is currently validating.
-
setValidate
public void setValidate(boolean validate) Description copied from interface:ProductCreator
Enable validation during getProducts method.- Specified by:
setValidate
in interfaceProductCreator
- Parameters:
validate
- boolean to enable/disable
-
getProducts
Implement the ProductCreator interface.- Specified by:
getProducts
in interfaceProductCreator
- Parameters:
file
- file or directory.- Returns:
- list of parsed products.
- Throws:
Exception
- if error occurs
-
getContentsXML
- Returns:
- XML contents
-
isSendOriginWhenPhasesExist
public boolean isSendOriginWhenPhasesExist()- Specified by:
isSendOriginWhenPhasesExist
in interfaceProductCreator
- Returns:
- boolean sendOriginWhenPhasesExist
-
setSendOriginWhenPhasesExist
public void setSendOriginWhenPhasesExist(boolean sendOriginWhenPhasesExist) Description copied from interface:ProductCreator
Enable sending origin when phases exist- Specified by:
setSendOriginWhenPhasesExist
in interfaceProductCreator
- Parameters:
sendOriginWhenPhasesExist
- boolean to set
-
setSendMechanismWhenPhasesExist
public void setSendMechanismWhenPhasesExist(boolean sendMechanismWhenPhasesExist) Description copied from interface:ProductCreator
Enable sending mechanism when phases exist- Specified by:
setSendMechanismWhenPhasesExist
in interfaceProductCreator
- Parameters:
sendMechanismWhenPhasesExist
- boolean to set
-
isSendMechanismWhenPhasesExist
public boolean isSendMechanismWhenPhasesExist()- Specified by:
isSendMechanismWhenPhasesExist
in interfaceProductCreator
- Returns:
- sendMechanismWhenPhasesExist boolean
-
setPadForBase64Bug
public void setPadForBase64Bug(boolean padForBase64Bug) - Parameters:
padForBase64Bug
- to set
-
isPadForBase64Bug
public boolean isPadForBase64Bug()- Returns:
- padForBase64Bug
-
fixRawQuakeml
Fixes base 64 bug: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8222187- Parameters:
rawMessage
- the message to edit- Returns:
- the fixed string
-
main
Convert quakeml files to products.- Parameters:
args
- a list of files to convert from quakeml to products.- Throws:
Exception
- if error occurs
-