Class QuakemlProductCreator

java.lang.Object
gov.usgs.earthquake.distribution.QuakemlProductCreator
All Implemented Interfaces:
ProductCreator

public class QuakemlProductCreator extends Object implements ProductCreator
Create Products from ANSS Quakeml files.
  • Field Details

    • LOGGER

      public static final Logger LOGGER
      For use in logging issues
    • XML_CONTENT_TYPE

      public static final String XML_CONTENT_TYPE
      Content type for xml
      See Also:
    • QUAKEML_CONTENT_PATH

      public static final String QUAKEML_CONTENT_PATH
      Content path for quakeml
      See Also:
    • CONTENTS_XML_PATH

      public static final String CONTENTS_XML_PATH
      Contents XML path
      See Also:
    • METERS_PER_KILOMETER

      public static final BigDecimal METERS_PER_KILOMETER
      Var for number of meters/kilometer...
    • VERSION

      public static final String 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

      public List<Product> getQuakemlProducts(org.quakeml_1_2.Quakeml message) throws Exception
      Gets Quakeml products with no rawQuakeml
      Parameters:
      message - Parsed quakeml message
      Returns:
      List of products
      Throws:
      Exception - if error occurs
    • getQuakemlProducts

      public List<Product> getQuakemlProducts(String message) throws Exception
      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. Calls getEventProducts(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. Calls getEventProducts(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 - Quakeml
      event - the event element in the quakeml message
      mech - A focal mechanism
      quakemlContent - 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 add
      name - of property
      value - 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 add
      name - of property
      value - of property
      allowExponential - if allowed
    • setProperty

      public void setProperty(Map<String,String> properties, String name, String value)
      setProperty for strings
      Parameters:
      properties - to add
      name - of property
      value - of property
    • setProperty

      public void setProperty(Map<String,String> properties, String name, org.quakeml_1_2.TimeQuantity value)
      setProperty for TimeQuantities
      Parameters:
      properties - to add
      name - of property
      value - of property
    • setProperty

      public void setProperty(Map<String,String> properties, String name, BigDecimal value)
      setProperty taking in BigDecimals. No exponentials
      Parameters:
      properties - to add
      name - of property
      value - of property
    • setProperty

      public void setProperty(Map<String,String> properties, String name, BigDecimal value, boolean allowExponential)
      setProperty taking in BigDecimals
      Parameters:
      properties - to add
      name - of property
      value - of property
      allowExponential - boolean
    • setProperty

      public void setProperty(Map<String,String> properties, String name, BigInteger value)
      setProperty taking in BigIntegers. No exponentials
      Parameters:
      properties - to add
      name - of property
      value - of property
    • setProperty

      public void setProperty(Map<String,String> properties, String name, Integer value)
      setProperty taking in Integers
      Parameters:
      properties - to add
      name - of property
      value - 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 interface ProductCreator
      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 interface ProductCreator
      Parameters:
      validate - boolean to enable/disable
    • getProducts

      public List<Product> getProducts(File file) throws Exception
      Implement the ProductCreator interface.
      Specified by:
      getProducts in interface ProductCreator
      Parameters:
      file - file or directory.
      Returns:
      list of parsed products.
      Throws:
      Exception - if error occurs
    • getContentsXML

      protected Content getContentsXML()
      Returns:
      XML contents
    • isSendOriginWhenPhasesExist

      public boolean isSendOriginWhenPhasesExist()
      Specified by:
      isSendOriginWhenPhasesExist in interface ProductCreator
      Returns:
      boolean sendOriginWhenPhasesExist
    • setSendOriginWhenPhasesExist

      public void setSendOriginWhenPhasesExist(boolean sendOriginWhenPhasesExist)
      Description copied from interface: ProductCreator
      Enable sending origin when phases exist
      Specified by:
      setSendOriginWhenPhasesExist in interface ProductCreator
      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 interface ProductCreator
      Parameters:
      sendMechanismWhenPhasesExist - boolean to set
    • isSendMechanismWhenPhasesExist

      public boolean isSendMechanismWhenPhasesExist()
      Specified by:
      isSendMechanismWhenPhasesExist in interface ProductCreator
      Returns:
      sendMechanismWhenPhasesExist boolean
    • setPadForBase64Bug

      public void setPadForBase64Bug(boolean padForBase64Bug)
      Parameters:
      padForBase64Bug - to set
    • isPadForBase64Bug

      public boolean isPadForBase64Bug()
      Returns:
      padForBase64Bug
    • fixRawQuakeml

      public String fixRawQuakeml(String rawMessage)
      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

      public static void main(String[] args) throws Exception
      Convert quakeml files to products.
      Parameters:
      args - a list of files to convert from quakeml to products.
      Throws:
      Exception - if error occurs