Package org.quartz

Class JobDataMap

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,​java.lang.Object>

    public class JobDataMap
    extends StringKeyDirtyFlagMap
    implements java.io.Serializable
    Holds state information for Job instances.

    JobDataMap instances are stored once when the Job is added to a scheduler. They are also re-persisted after every execution of jobs annotated with @PersistJobDataAfterExecution.

    JobDataMap instances can also be stored with a Trigger. This can be useful in the case where you have a Job that is stored in the scheduler for regular/repeated use by multiple Triggers, yet with each independent triggering, you want to supply the Job with different data inputs.

    The JobExecutionContext passed to a Job at execution time also contains a convenience JobDataMap that is the result of merging the contents of the trigger's JobDataMap (if any) over the Job's JobDataMap (if any).

    Update since 2.2.4 - We keep an dirty flag for this map so that whenever you modify(add/delete) any of the entries, it will set to "true". However if you create new instance using an existing map with JobDataMap(Map), then the dirty flag will NOT be set to "true" until you modify the instance.

    Author:
    James House
    See Also:
    Job, PersistJobDataAfterExecution, Trigger, JobExecutionContext, Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Constructor Summary

      Constructors 
      Constructor Description
      JobDataMap()
      Create an empty JobDataMap.
      JobDataMap​(java.util.Map<?,​?> map)
      Create a JobDataMap with the given data.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Boolean getBooleanFromString​(java.lang.String key)
      Retrieve the identified Boolean value from the JobDataMap.
      boolean getBooleanValue​(java.lang.String key)
      Retrieve the identified boolean value from the JobDataMap.
      boolean getBooleanValueFromString​(java.lang.String key)
      Retrieve the identified boolean value from the JobDataMap.
      java.lang.Character getCharacterFromString​(java.lang.String key)
      Retrieve the identified Character value from the JobDataMap.
      char getCharFromString​(java.lang.String key)
      Retrieve the identified char value from the JobDataMap.
      java.lang.Double getDoubleFromString​(java.lang.String key)
      Retrieve the identified Double value from the JobDataMap.
      double getDoubleValue​(java.lang.String key)
      Retrieve the identified double value from the JobDataMap.
      double getDoubleValueFromString​(java.lang.String key)
      Retrieve the identified double value from the JobDataMap.
      java.lang.Float getFloatFromString​(java.lang.String key)
      Retrieve the identified Float value from the JobDataMap.
      float getFloatValue​(java.lang.String key)
      Retrieve the identified float value from the JobDataMap.
      float getFloatValueFromString​(java.lang.String key)
      Retrieve the identified float value from the JobDataMap.
      java.lang.Integer getIntegerFromString​(java.lang.String key)
      Retrieve the identified int value from the JobDataMap.
      int getIntFromString​(java.lang.String key)
      Retrieve the identified int value from the JobDataMap.
      int getIntValue​(java.lang.String key)
      Retrieve the identified int value from the JobDataMap.
      java.lang.Long getLongFromString​(java.lang.String key)
      Retrieve the identified Long value from the JobDataMap.
      long getLongValue​(java.lang.String key)
      Retrieve the identified long value from the JobDataMap.
      long getLongValueFromString​(java.lang.String key)
      Retrieve the identified long value from the JobDataMap.
      void putAsString​(java.lang.String key, boolean value)
      Adds the given boolean value as a string version to the Job's data map.
      void putAsString​(java.lang.String key, char value)
      Adds the given char value as a string version to the Job's data map.
      void putAsString​(java.lang.String key, double value)
      Adds the given double value as a string version to the Job's data map.
      void putAsString​(java.lang.String key, float value)
      Adds the given float value as a string version to the Job's data map.
      void putAsString​(java.lang.String key, int value)
      Adds the given int value as a string version to the Job's data map.
      void putAsString​(java.lang.String key, long value)
      Adds the given long value as a string version to the Job's data map.
      void putAsString​(java.lang.String key, java.lang.Boolean value)
      Adds the given Boolean value as a string version to the Job's data map.
      void putAsString​(java.lang.String key, java.lang.Character value)
      Adds the given Character value as a string version to the Job's data map.
      void putAsString​(java.lang.String key, java.lang.Double value)
      Adds the given Double value as a string version to the Job's data map.
      void putAsString​(java.lang.String key, java.lang.Float value)
      Adds the given Float value as a string version to the Job's data map.
      void putAsString​(java.lang.String key, java.lang.Integer value)
      Adds the given Integer value as a string version to the Job's data map.
      void putAsString​(java.lang.String key, java.lang.Long value)
      Adds the given Long value as a string version to the Job's data map.
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Constructor Detail

      • JobDataMap

        public JobDataMap()

        Create an empty JobDataMap.

      • JobDataMap

        public JobDataMap​(java.util.Map<?,​?> map)

        Create a JobDataMap with the given data.

    • Method Detail

      • putAsString

        public void putAsString​(java.lang.String key,
                                boolean value)

        Adds the given boolean value as a string version to the Job's data map.

      • putAsString

        public void putAsString​(java.lang.String key,
                                java.lang.Boolean value)

        Adds the given Boolean value as a string version to the Job's data map.

      • putAsString

        public void putAsString​(java.lang.String key,
                                char value)

        Adds the given char value as a string version to the Job's data map.

      • putAsString

        public void putAsString​(java.lang.String key,
                                java.lang.Character value)

        Adds the given Character value as a string version to the Job's data map.

      • putAsString

        public void putAsString​(java.lang.String key,
                                double value)

        Adds the given double value as a string version to the Job's data map.

      • putAsString

        public void putAsString​(java.lang.String key,
                                java.lang.Double value)

        Adds the given Double value as a string version to the Job's data map.

      • putAsString

        public void putAsString​(java.lang.String key,
                                float value)

        Adds the given float value as a string version to the Job's data map.

      • putAsString

        public void putAsString​(java.lang.String key,
                                java.lang.Float value)

        Adds the given Float value as a string version to the Job's data map.

      • putAsString

        public void putAsString​(java.lang.String key,
                                int value)

        Adds the given int value as a string version to the Job's data map.

      • putAsString

        public void putAsString​(java.lang.String key,
                                java.lang.Integer value)

        Adds the given Integer value as a string version to the Job's data map.

      • putAsString

        public void putAsString​(java.lang.String key,
                                long value)

        Adds the given long value as a string version to the Job's data map.

      • putAsString

        public void putAsString​(java.lang.String key,
                                java.lang.Long value)

        Adds the given Long value as a string version to the Job's data map.

      • getIntFromString

        public int getIntFromString​(java.lang.String key)

        Retrieve the identified int value from the JobDataMap.

        Throws:
        java.lang.ClassCastException - if the identified object is not a String.
      • getIntValue

        public int getIntValue​(java.lang.String key)

        Retrieve the identified int value from the JobDataMap.

        Throws:
        java.lang.ClassCastException - if the identified object is not a String or Integer.
      • getIntegerFromString

        public java.lang.Integer getIntegerFromString​(java.lang.String key)

        Retrieve the identified int value from the JobDataMap.

        Throws:
        java.lang.ClassCastException - if the identified object is not a String.
      • getBooleanValueFromString

        public boolean getBooleanValueFromString​(java.lang.String key)

        Retrieve the identified boolean value from the JobDataMap.

        Throws:
        java.lang.ClassCastException - if the identified object is not a String.
      • getBooleanValue

        public boolean getBooleanValue​(java.lang.String key)

        Retrieve the identified boolean value from the JobDataMap.

        Throws:
        java.lang.ClassCastException - if the identified object is not a String or Boolean.
      • getBooleanFromString

        public java.lang.Boolean getBooleanFromString​(java.lang.String key)

        Retrieve the identified Boolean value from the JobDataMap.

        Throws:
        java.lang.ClassCastException - if the identified object is not a String.
      • getCharFromString

        public char getCharFromString​(java.lang.String key)

        Retrieve the identified char value from the JobDataMap.

        Throws:
        java.lang.ClassCastException - if the identified object is not a String.
      • getCharacterFromString

        public java.lang.Character getCharacterFromString​(java.lang.String key)

        Retrieve the identified Character value from the JobDataMap.

        Throws:
        java.lang.ClassCastException - if the identified object is not a String.
      • getDoubleValueFromString

        public double getDoubleValueFromString​(java.lang.String key)

        Retrieve the identified double value from the JobDataMap.

        Throws:
        java.lang.ClassCastException - if the identified object is not a String.
      • getDoubleValue

        public double getDoubleValue​(java.lang.String key)

        Retrieve the identified double value from the JobDataMap.

        Throws:
        java.lang.ClassCastException - if the identified object is not a String or Double.
      • getDoubleFromString

        public java.lang.Double getDoubleFromString​(java.lang.String key)

        Retrieve the identified Double value from the JobDataMap.

        Throws:
        java.lang.ClassCastException - if the identified object is not a String.
      • getFloatValueFromString

        public float getFloatValueFromString​(java.lang.String key)

        Retrieve the identified float value from the JobDataMap.

        Throws:
        java.lang.ClassCastException - if the identified object is not a String.
      • getFloatValue

        public float getFloatValue​(java.lang.String key)

        Retrieve the identified float value from the JobDataMap.

        Throws:
        java.lang.ClassCastException - if the identified object is not a String or Float.
      • getFloatFromString

        public java.lang.Float getFloatFromString​(java.lang.String key)

        Retrieve the identified Float value from the JobDataMap.

        Throws:
        java.lang.ClassCastException - if the identified object is not a String.
      • getLongValueFromString

        public long getLongValueFromString​(java.lang.String key)

        Retrieve the identified long value from the JobDataMap.

        Throws:
        java.lang.ClassCastException - if the identified object is not a String.
      • getLongValue

        public long getLongValue​(java.lang.String key)

        Retrieve the identified long value from the JobDataMap.

        Throws:
        java.lang.ClassCastException - if the identified object is not a String or Long.
      • getLongFromString

        public java.lang.Long getLongFromString​(java.lang.String key)

        Retrieve the identified Long value from the JobDataMap.

        Throws:
        java.lang.ClassCastException - if the identified object is not a String.