Class QuakemlProductCreator

  • All Implemented Interfaces:
    ProductCreator

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

      Fields 
      Modifier and Type Field Description
      static java.lang.String CONTENTS_XML_PATH
      Contents XML path
      static java.util.logging.Logger LOGGER
      For use in logging issues
      static java.math.BigDecimal METERS_PER_KILOMETER
      Var for number of meters/kilometer...
      static java.lang.String QUAKEML_CONTENT_PATH
      Content path for quakeml
      static java.lang.String VERSION
      Version
      static java.lang.String XML_CONTENT_TYPE
      Content type for xml
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String fixRawQuakeml​(java.lang.String rawMessage)
      Fixes base 64 bug: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8222187
      protected Content getContentsXML()  
      gov.usgs.earthquake.quakeml.FileToQuakemlConverter getConverter()  
      java.util.List<Product> 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, java.lang.String quakemlContent)  
      java.util.List<Product> getInternalEventProducts​(org.quakeml_1_2.Quakeml message, org.quakeml_1_2.InternalEvent event)
      Get internal products in quakeml event element.
      java.util.List<Product> getProducts​(java.io.File file)
      Implement the ProductCreator interface.
      java.util.List<Product> getQuakemlProducts​(java.lang.String message)
      Gets Quakeml products with the message as a rawQuakeml
      java.util.List<Product> getQuakemlProducts​(org.quakeml_1_2.Quakeml message)
      Gets Quakeml products with no rawQuakeml
      java.util.List<Product> getQuakemlProducts​(org.quakeml_1_2.Quakeml message, java.lang.String rawQuakeml)
      Get products in a quakeml message.
      java.util.List<Product> getScenarioEventProducts​(org.quakeml_1_2.Quakeml message, org.quakeml_1_2.ScenarioEvent event)
      Get scenario products in quakeml event element.
      boolean isPadForBase64Bug()  
      boolean isSendMechanismWhenPhasesExist()  
      boolean isSendOriginWhenPhasesExist()  
      boolean isValidate()  
      static void main​(java.lang.String[] args)
      Convert quakeml files to products.
      void setConverter​(gov.usgs.earthquake.quakeml.FileToQuakemlConverter converter)  
      void setPadForBase64Bug​(boolean padForBase64Bug)  
      void setProperty​(java.util.Map<java.lang.String,​java.lang.String> properties, java.lang.String name, java.lang.Integer value)
      setProperty taking in Integers
      void setProperty​(java.util.Map<java.lang.String,​java.lang.String> properties, java.lang.String name, java.lang.String value)
      setProperty for strings
      void setProperty​(java.util.Map<java.lang.String,​java.lang.String> properties, java.lang.String name, java.math.BigDecimal value)
      setProperty taking in BigDecimals.
      void setProperty​(java.util.Map<java.lang.String,​java.lang.String> properties, java.lang.String name, java.math.BigDecimal value, boolean allowExponential)
      setProperty taking in BigDecimals
      void setProperty​(java.util.Map<java.lang.String,​java.lang.String> properties, java.lang.String name, java.math.BigInteger value)
      setProperty taking in BigIntegers.
      void setProperty​(java.util.Map<java.lang.String,​java.lang.String> properties, java.lang.String name, org.quakeml_1_2.RealQuantity value)
      setProperty for RealQuantity values.
      void setProperty​(java.util.Map<java.lang.String,​java.lang.String> properties, java.lang.String name, org.quakeml_1_2.RealQuantity value, boolean allowExponential)
      setProperty for RealQuantity values
      void setProperty​(java.util.Map<java.lang.String,​java.lang.String> properties, java.lang.String name, org.quakeml_1_2.TimeQuantity value)
      setProperty for TimeQuantities
      void setSendMechanismWhenPhasesExist​(boolean sendMechanismWhenPhasesExist)  
      void setSendOriginWhenPhasesExist​(boolean sendOriginWhenPhasesExist)  
      void setValidate​(boolean validate)
      Enable validation during getProducts method.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGGER

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

        public static final java.lang.String XML_CONTENT_TYPE
        Content type for xml
        See Also:
        Constant Field Values
      • QUAKEML_CONTENT_PATH

        public static final java.lang.String QUAKEML_CONTENT_PATH
        Content path for quakeml
        See Also:
        Constant Field Values
      • CONTENTS_XML_PATH

        public static final java.lang.String CONTENTS_XML_PATH
        Contents XML path
        See Also:
        Constant Field Values
      • METERS_PER_KILOMETER

        public static final java.math.BigDecimal METERS_PER_KILOMETER
        Var for number of meters/kilometer...
    • Constructor Detail

      • 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 Detail

      • getQuakemlProducts

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

        public java.util.List<Product> getQuakemlProducts​(java.lang.String message)
                                                   throws java.lang.Exception
        Gets Quakeml products with the message as a rawQuakeml
        Parameters:
        message - Parsed quakeml message
        Returns:
        List of products
        Throws:
        java.lang.Exception - if error occurs
      • getQuakemlProducts

        public java.util.List<Product> getQuakemlProducts​(org.quakeml_1_2.Quakeml message,
                                                          java.lang.String rawQuakeml)
                                                   throws java.lang.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:
        java.lang.Exception - if error occurs
      • getInternalEventProducts

        public java.util.List<Product> getInternalEventProducts​(org.quakeml_1_2.Quakeml message,
                                                                org.quakeml_1_2.InternalEvent event)
                                                         throws java.lang.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:
        java.lang.Exception - if error occurs
      • getScenarioEventProducts

        public java.util.List<Product> getScenarioEventProducts​(org.quakeml_1_2.Quakeml message,
                                                                org.quakeml_1_2.ScenarioEvent event)
                                                         throws java.lang.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:
        java.lang.Exception - if error occurs
      • getEventProducts

        public java.util.List<Product> getEventProducts​(org.quakeml_1_2.Quakeml message,
                                                        org.quakeml_1_2.Event event)
                                                 throws java.lang.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:
        java.lang.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,
                                                   java.lang.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​(java.util.Map<java.lang.String,​java.lang.String> properties,
                                java.lang.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​(java.util.Map<java.lang.String,​java.lang.String> properties,
                                java.lang.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​(java.util.Map<java.lang.String,​java.lang.String> properties,
                                java.lang.String name,
                                java.lang.String value)
        setProperty for strings
        Parameters:
        properties - to add
        name - of property
        value - of property
      • setProperty

        public void setProperty​(java.util.Map<java.lang.String,​java.lang.String> properties,
                                java.lang.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​(java.util.Map<java.lang.String,​java.lang.String> properties,
                                java.lang.String name,
                                java.math.BigDecimal value)
        setProperty taking in BigDecimals. No exponentials
        Parameters:
        properties - to add
        name - of property
        value - of property
      • setProperty

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

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

        public void setProperty​(java.util.Map<java.lang.String,​java.lang.String> properties,
                                java.lang.String name,
                                java.lang.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 java.util.List<Product> getProducts​(java.io.File file)
                                            throws java.lang.Exception
        Implement the ProductCreator interface.
        Specified by:
        getProducts in interface ProductCreator
        Parameters:
        file - file or directory.
        Returns:
        list of parsed products.
        Throws:
        java.lang.Exception - if error occurs
      • getContentsXML

        protected Content getContentsXML()
        Returns:
        XML contents
      • isSendOriginWhenPhasesExist

        public boolean isSendOriginWhenPhasesExist()
        Returns:
        boolean sendOriginWhenPhasesExist
      • setSendOriginWhenPhasesExist

        public void setSendOriginWhenPhasesExist​(boolean sendOriginWhenPhasesExist)
        Parameters:
        sendOriginWhenPhasesExist - boolean to set
      • setSendMechanismWhenPhasesExist

        public void setSendMechanismWhenPhasesExist​(boolean sendMechanismWhenPhasesExist)
        Parameters:
        sendMechanismWhenPhasesExist - boolean to set
      • isSendMechanismWhenPhasesExist

        public boolean isSendMechanismWhenPhasesExist()
        Returns:
        sendMechanismWhenPhasesExist boolean
      • setPadForBase64Bug

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

        public boolean isPadForBase64Bug()
        Returns:
        padForBase64Bug
      • fixRawQuakeml

        public java.lang.String fixRawQuakeml​(java.lang.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​(java.lang.String[] args)
                         throws java.lang.Exception
        Convert quakeml files to products.
        Parameters:
        args - a list of files to convert from quakeml to products.
        Throws:
        java.lang.Exception - if error occurs