Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.hyades.logging.events.cbe.util
Class EventHelpers

    java.lang.Object
      |
      +--org.eclipse.hyades.logging.events.cbe.util.EventHelpers

public class EventHelpers
extends java.lang.Object

Miscellaneous routines to support functions such as validation, serialization and comparison.

Since:
  1.0.1
Version:
  1.0.1
Author:
  Denilson Nastacio, Jason Cornpropst, Scott Brown, Paul E. Slauenwhite, Adriana Viman

Field Summary
`static java.lang.Object` | `LOCK` Deprecated. As of 3.1, the event object is used to synchronize its operations.

Constructor Summary
`EventHelpers()`

Method Summary
`static boolean` | `compareEObject(java.lang.Object obj1, java.lang.Object obj2)` Deep-comparison for two EMF objects.
`static ExtendedDataElement` | `convertToExtendedDataElement(java.lang.Throwable throwable)` Maps data of the parameter `java.lang.Throwable` object to an Extended Data Element.
`static ExtendedDataElement` | `convertToExtendedDataElement(java.lang.Throwable throwable, java.lang.String name)` Maps data of the parameter `java.lang.Throwable` object to an Extended Data Element with the parameter `name`.
`static long` | `dateToLong(java.lang.String xsdDateTimeString)` Converts the creationTime from a string in XML Schema dateTime format (CCYY-MM-DDThh:mm:ss) to a long representing the milliseconds since 1970-01-01T00:00:00
`static java.lang.String[]` | `getExtendedDataElementValuesArray(java.lang.String values)` Convenience API to transpose a `values` string to a `values` array, thereby ensuring the parameter `values` string does not exceed the 1024 character limit, as stated in the Common Base Event v1.0.1 specification.
`static java.lang.String` | `getFormattedDateString(long dateInMillis)` Converts a long representing a coordinated universal time (UTC) date in milliseconds to a formatted string using the default date format pattern.
`static java.lang.String` | `getFormattedDateString(long dateInMillis, java.lang.String dateFormatPattern)` Converts a long representing a coordinated universal time (UTC) date in milliseconds to a formatted string using the parameter date format pattern.
`static java.lang.String` | `getFormattedDateString(java.lang.String xsdDateTimeString)` Converts a string representing an XML Schema dateTime (e.g. yyyy-MM-ddTHH:mm:ss) date to a formatted string using the default date format pattern.
`static java.lang.String` | `getFormattedDateString(java.lang.String xsdDateTimeString, java.lang.String dateFormatPattern)` Converts a string representing an XML Schema dateTime (e.g. yyyy-MM-ddTHH:mm:ss) date to a formatted string using the parameter date format pattern.
`static java.lang.String` | `getString(java.lang.String key)`
`static java.lang.String` | `getString(java.lang.String key, java.lang.Object argument)`
`static java.lang.String` | `getString(java.lang.String key, java.lang.Object[] arguments)`
`static java.lang.String` | `getString(java.lang.String key, java.lang.Object argumentA, java.lang.Object argumentB)`
`static java.lang.String` | `getString(java.lang.String key, java.lang.Object argumentA, java.lang.Object argumentB, java.lang.Object argumentC)`
`static java.lang.String` | `getString(java.lang.String key, java.lang.Object argumentA, java.lang.Object argumentB, java.lang.Object argumentC, java.lang.Object argumentD)`
`static java.lang.String` | `longToDate(long dateInMillis)` Converts a long representing UTC in milliseconds to the XML Schema datetime format (CCYY-MM-DDThh:mm:ssZ)
`static void` | `serializableRead(org.eclipse.emf.ecore.EObject o, java.io.ObjectInputStream in)` Generic serialization routine for EMF object.
`static void` | `serializableWrite(org.eclipse.emf.ecore.EObject o, java.io.ObjectOutputStream out)` Generic serialization routine for EMF object.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### LOCK

    public static final java.lang.Object LOCK

  Deprecated. As of 3.1, the event object is used to synchronize its operations.

  Current thread lock for synchronization.

Constructor Detail

### EventHelpers

    public EventHelpers()

Method Detail

### serializableRead

    public static void serializableRead(org.eclipse.emf.ecore.EObject o,
                                        java.io.ObjectInputStream in)
                                 throws java.lang.ClassNotFoundException,
                                        java.io.IOException

  Generic serialization routine for EMF object.

  Parameters:
    `o` - EMF object to be serialized
    `in` - Java IO input stream contained the serialized strem
  Throws:
    `java.lang.ClassNotFoundException` - if the class of an object inside the stream cannot be found in the classpath
    `java.io.IOException` - if the input stream cannot be read for whatever reason

### serializableWrite

    public static void serializableWrite(org.eclipse.emf.ecore.EObject o,
                                         java.io.ObjectOutputStream out)
                                  throws java.io.IOException

  Generic serialization routine for EMF object.

  Parameters:
    `o` - EMF object to be serialized
    `out` - Java IO stream to where the serialized object will be written.
  Throws:
    `java.io.IOException` - if the object cannot be written to the output stream for whatever reason.

### compareEObject

    public static boolean compareEObject(java.lang.Object obj1,
                                         java.lang.Object obj2)

  Deep-comparison for two EMF objects.

  If the the two EMF objects are of the same type, it traverses their features recursively until a difference is found.

  When comparing lists, this method ignores order.

  This is a helper for implementing the `equals` method on EMF objects, where `obj1` is the object where `equals` was called and `obj2` is the parameter for that call.

  Therefore `obj1` can never be `null` and when `obj2` is `null`, the result is `false`.

  Parameters:
    `obj1` - first element in the comparison
    `obj2` - second element in the comparison
  Returns:
    `true` if the two objects are identical instancesor `false` otherwise.

### dateToLong

    public static long dateToLong(java.lang.String xsdDateTimeString)

  Converts the creationTime from a string in XML Schema dateTime format (CCYY-MM-DDThh:mm:ss) to a long representing the milliseconds since 1970-01-01T00:00:00

  Parameters:
    `xsdDateTimeString` - A string representing an XML Schema dateTime (e.g. yyyy-MM-ddTHH:mm:ss) date.
  Returns:
    The date in milliseconds since 1970-01-01T00:00:00Z. If the input cannot be converted or the date is older than 1970 then zero will be returned.
  Throws:
    `java.lang.IllegalArgumentException` - If the string representing an XML Schema dateTime (e.g. yyyy-MM-ddTHH:mm:ss) date is invalid.
  See Also:
    `CommonBaseEvent.getCreationTimeAsLong()`

### longToDate

    public static java.lang.String longToDate(long dateInMillis)

  Converts a long representing UTC in milliseconds to the XML Schema datetime format (CCYY-MM-DDThh:mm:ssZ)

  Parameters:
    `dateInMillis` - A long representing a coordinated universal time (UTC) time stamp in milliseconds.
  Returns:
    The date in string format (CCYY-MM-DDThh:mm:ssZ)
  Throws:
    `java.lang.IllegalArgumentException` - If the long representing a coordinated universal time (UTC) time stamp in milliseconds is negative.
  See Also:
    `CommonBaseEvent.setCreationTimeAsLong(long)`

### getString

    public static java.lang.String getString(java.lang.String key)

### getString

    public static java.lang.String getString(java.lang.String key,
                                             java.lang.Object argument)

### getString

    public static java.lang.String getString(java.lang.String key,
                                             java.lang.Object argumentA,
                                             java.lang.Object argumentB)

### getString

    public static java.lang.String getString(java.lang.String key,
                                             java.lang.Object argumentA,
                                             java.lang.Object argumentB,
                                             java.lang.Object argumentC)

### getString

    public static java.lang.String getString(java.lang.String key,
                                             java.lang.Object argumentA,
                                             java.lang.Object argumentB,
                                             java.lang.Object argumentC,
                                             java.lang.Object argumentD)

### getString

    public static java.lang.String getString(java.lang.String key,
                                             java.lang.Object[] arguments)

### convertToExtendedDataElement

    public static ExtendedDataElement convertToExtendedDataElement(java.lang.Throwable throwable)

  Maps data of the parameter `java.lang.Throwable` object to an Extended Data Element.

  This API provides a structured representation of the parameter `java.lang.Throwable` object as an Extended Data Element with the following advantages:

  - Efficient specialized parsibility and de-/serialization.
  - Identifiable Extended Data Element `name`s (e.g. "Throwable" and "Cause")
  - Captures all nested causal `java.lang.Throwable`s.
  - Adheres to the 1024-character restriction imposed on the Extended Data Element `values`.

  NOTE: This API invoked in JRE 1.3.x and below run-time environments parses the stack trace produced by the `java.lang.Throwable`'s `printStackTrace()` API (e.g. no causal `java.lang.Throwable`(s)). Alternatively, this API invoked in JRE 1.4.x and above run-time environments utilizes the `java.lang.Throwable`'s causal `java.lang.Throwable` and `StackTraceElement`(s) properties.

  This API uses the following mapping to convert the parameter `java.lang.Throwable` object to an Extended Data Element:

  - name = "Throwable"
  - type = "stringArray"
  - values[0...n] = < `java.lang.Throwable`'s class name>[: < `java.lang.Throwable`'s localized message>]
  - values[(n + 1)...m] = < `java.lang.Throwable`'s stackTraceElement[0...(m - (n + 1))]>
  - children[0] = < `java.lang.Throwable`'s cause>

  This API uses the following mapping to convert the parameter `java.lang.Throwable` object to an Extended Data Element if the parameter `java.lang.Throwable` object is `null`:

  - name = <name>
  - type = "stringArray"
  - values[0] = `null`

  Causal `java.lang.Throwable`s are recursively converted to Extended Data Elements using the following mapping:

  - name = "Cause"
  - type = "stringArray"
  - values[0...n] = <cause's class name>[: <cause's localized message>]
  - values[(n + 1)...m] = <cause's stackTraceElement[0...(m - (n + 1))]>
  - [children[0] = <cause's cause>]

  ...

  NOTE: When the `java.lang.Throwable`'s class name and localized message are greater than 1024 characters, the resultant class name and localized message string is segmented into a the first 1024-character elements of the `values` property. As such, the `java.lang.Throwable`'s stack trace elements are transposed by the number of 1024-character elements in the `values` property.

  Parameters:
    `throwable` - The `java.lang.Throwable` object to be converted to an Extended Data Element.
  Returns:
    The Extended Data Element representation of the parameter `java.lang.Throwable` object.

### convertToExtendedDataElement

    public static ExtendedDataElement convertToExtendedDataElement(java.lang.Throwable throwable,
                                                                   java.lang.String name)

  Maps data of the parameter `java.lang.Throwable` object to an Extended Data Element with the parameter `name`.

  This API provides a structured representation of the parameter `java.lang.Throwable` object as an Extended Data Element with the following advantages:

  - Efficient specialized parsibility and de-/serialization.
  - Identifiable Extended Data Element `name`s (e.g. <name> and "Cause")
  - Captures all nested causal `java.lang.Throwable`s.
  - Adheres to the 1024-character restriction imposed on the Extended Data Element `values`.

  NOTE: This API invoked in JRE 1.3.x and below run-time environments parses the stack trace produced by the `java.lang.Throwable`'s `printStackTrace()` API (e.g. no causal `java.lang.Throwable`(s)). Alternatively, this API invoked in JRE 1.4.x and above run-time environments utilizes the `java.lang.Throwable`'s causal `java.lang.Throwable` and `StackTraceElement`(s) properties.

  This API uses the following mapping to convert the parameter `java.lang.Throwable` object to an Extended Data Element:

  - name = <name>
  - type = "stringArray"
  - values[0...n] = < `java.lang.Throwable`'s class name>[: < `java.lang.Throwable`'s localized message>]
  - values[(n + 1)...m] = < `java.lang.Throwable`'s stackTraceElement[0...(m - (n + 1))]>
  - children[0] = < `java.lang.Throwable`'s cause>

  This API uses the following mapping to convert the parameter `java.lang.Throwable` object to an Extended Data Element if the parameter `java.lang.Throwable` object is `null`:

  - name = <name>
  - type = "stringArray"
  - values[0] = `null`

  Causal `java.lang.Throwable`s are recursively converted to Extended Data Elements using the following mapping:

  - name = "Cause"
  - type = "stringArray"
  - values[0...n] = <cause's class name>[: <cause's localized message>]
  - values[(n + 1)...m] = <cause's stackTraceElement[0...(m - (n + 1))]>
  - [children[0] = <cause's cause>]

  ...

  NOTE: When the `java.lang.Throwable`'s class name and localized message are greater than 1024 characters, the resultant class name and localized message string is segmented into a the first 1024-character elements of the `values` property. As such, the `java.lang.Throwable`'s stack trace elements are transposed by the number of 1024-character elements in the `values` property.

  Parameters:
    `throwable` - The `java.lang.Throwable` object to be converted to an Extended Data Element.
    `name` - The `name` property of the Extended Data Element.
  Returns:
    The Extended Data Element representation of the parameter `java.lang.Throwable` object.

### getExtendedDataElementValuesArray

    public static java.lang.String[] getExtendedDataElementValuesArray(java.lang.String values)

  Convenience API to transpose a `values` string to a `values` array, thereby ensuring the parameter `values` string does not exceed the 1024 character limit, as stated in the Common Base Event v1.0.1 specification.

  If the parameter `values` property is larger than 1024 characters, the string is segmented into a String array of 1024-character elements. However, if the parameter `values` property is 1024 or less characters or `null`, the string is set directly on the first element a String array.

  Parameters:
    `values` - The values string to be transposed to a values array.

### getFormattedDateString

    public static java.lang.String getFormattedDateString(long dateInMillis)
                                                   throws java.lang.IllegalArgumentException

  Converts a long representing a coordinated universal time (UTC) date in milliseconds to a formatted string using the default date format pattern.

  The default date format is:

  MMMM d, yyyy h:mm:ss.SSS a z

  For more information on the meaning of the individual symbols in the default date format pattern, see the class comment header for `java.util.SimpleTimeZone`.

  The time zone of the returned string is coordinated universal time (UTC), represented as Greenwich Mean Time (GMT).

  Parameters:
    `dateInMillis` - A long representing a coordinated universal time (UTC) time stamp in milliseconds.
  Returns:
    The date as a formatted string using the default date format pattern (e.g. MMMM d, yyyy h:mm:ss.SSS a z).
  Throws:
    `java.lang.IllegalArgumentException` - If the long representing a coordinated universal time (UTC) time stamp in milliseconds is negative.
  See Also:
    `SimpleTimeZone`

### getFormattedDateString

    public static java.lang.String getFormattedDateString(long dateInMillis,
                                                          java.lang.String dateFormatPattern)
                                                   throws java.lang.IllegalArgumentException

  Converts a long representing a coordinated universal time (UTC) date in milliseconds to a formatted string using the parameter date format pattern.

  For more information on the syntax and meaning of the individual symbols in the parameter date format pattern, see the class comment header for `java.util.SimpleTimeZone`.

  The time zone of the returned string is coordinated universal time (UTC), represented as Greenwich Mean Time (GMT).

  Parameters:
    `dateInMillis` - A long representing a coordinated universal time (UTC) time stamp in milliseconds.
    `dateFormatPattern` - The date format pattern (see `java.util.SimpleTimeZone`).
  Returns:
    The date as a formatted string using the parameter date format pattern.
  Throws:
    `java.lang.IllegalArgumentException` - If the long representing a coordinated universal time (UTC) time stamp in milliseconds is negative or the date format pattern (see `java.util.SimpleTimeZone`) is `null` or invalid.
  See Also:
    `SimpleTimeZone`

### getFormattedDateString

    public static java.lang.String getFormattedDateString(java.lang.String xsdDateTimeString)
                                                   throws java.lang.IllegalArgumentException

  Converts a string representing an XML Schema dateTime (e.g. yyyy-MM-ddTHH:mm:ss) date to a formatted string using the default date format pattern.

  For more information on the XML Schema dateTime (e.g. yyyy-MM-ddTHH:mm:ss) date, see http://www.w3.org/TR/NOTE-datetime.

  The default date format is:

  MMMM d, yyyy h:mm:ss.SSS a z

  For more information on the meaning of the individual symbols in the default date format pattern, see the class comment header for `java.util.SimpleTimeZone`.

  If the parameter string representing an XML Schema dateTime (e.g. yyyy-MM-ddTHH:mm:ss) date does not contain any time zone information, the time zone of the returned string is coordinated universal time (UTC), represented as Greenwich Mean Time (GMT). Otherwise, the time zone of the returned string is represented as a signed offset from Greenwich Mean Time (GMT). For example, 'GMT-05:00' for Eastern Standard Time.

  Parameters:
    `xsdDateTimeString` - A string representing an XML Schema dateTime (e.g. yyyy-MM-ddTHH:mm:ss) date.
  Returns:
    The date as a formatted string using the default date format pattern (e.g. MMMM d, yyyy h:mm:ss.SSS a z).
  Throws:
    `java.lang.IllegalArgumentException` - If the string representing an XML Schema dateTime (e.g. yyyy-MM-ddTHH:mm:ss) date is invalid.
  See Also:
    `SimpleTimeZone`

### getFormattedDateString

    public static java.lang.String getFormattedDateString(java.lang.String xsdDateTimeString,
                                                          java.lang.String dateFormatPattern)
                                                   throws java.lang.IllegalArgumentException

  Converts a string representing an XML Schema dateTime (e.g. yyyy-MM-ddTHH:mm:ss) date to a formatted string using the parameter date format pattern.

  For more information on the XML Schema dateTime (e.g. yyyy-MM-ddTHH:mm:ss) date, see http://www.w3.org/TR/NOTE-datetime.

  For more information on the syntax and meaning of the individual symbols in the parameter date format pattern, see the class comment header for `java.util.SimpleTimeZone`.

  If the parameter string representing an XML Schema dateTime (e.g. yyyy-MM-ddTHH:mm:ss) date does not contain any time zone information, the time zone of the returned string is coordinated universal time (UTC), represented as Greenwich Mean Time (GMT). Otherwise, the time zone of the returned string is represented as a signed offset from Greenwich Mean Time (GMT). For example, 'GMT-05:00' for Eastern Standard Time.

  Parameters:
    `xsdDateTimeString` - A string representing an XML Schema dateTime (e.g. yyyy-MM-ddTHH:mm:ss) date.
    `dateFormatPattern` - The date format pattern (see `java.util.SimpleTimeZone`).
  Returns:
    The date as a formatted string using the parameter date format pattern.
  Throws:
    `java.lang.IllegalArgumentException` - If the string representing an XML Schema dateTime (e.g. yyyy-MM-ddTHH:mm:ss) date is invalid or the date format pattern (see `java.util.SimpleTimeZone`) is `null` or invalid.
  See Also:
    `SimpleTimeZone`

Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD