org.apache.jmeter.save.converters

## Class ConversionHelp

- java.lang.Object
- - org.apache.jmeter.save.converters.ConversionHelp

-     public class ConversionHelp
      extends java.lang.Object

  Utility conversion routines for use with XStream

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `ATT_CLASS`
    `static java.lang.String` | `ATT_ELEMENT_TYPE`
    `static java.lang.String` | `ATT_NAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConversionHelp()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `cdata(byte[] chars, java.lang.String encoding)` Embed an array of bytes as a string with `encoding` in a xml-cdata section
    `static java.lang.String` | `decode(java.lang.String p)` Decode a string if `inVersion` equals `1.0`
    `static java.lang.String` | `encode(java.lang.String p)` Encode a string (if necessary) for output to a JTL file.
    `static java.lang.String` | `getPropertyName(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)` Get the property name, updating it if necessary using `NameUpdater`.
    `static java.lang.String` | `getPropertyValue(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context, java.lang.String name)` Get the property value, updating it if necessary using `NameUpdater`.
    `static java.lang.String` | `getUpgradePropertyName(java.lang.String name, com.thoughtworks.xstream.converters.UnmarshallingContext context)` Update a property name using `NameUpdater`.
    `static java.lang.String` | `getUpgradePropertyValue(java.lang.String name, java.lang.String value, com.thoughtworks.xstream.converters.UnmarshallingContext context)` Update a property value using `NameUpdater.getCurrentName(String, String, String)`.
    `static boolean` | `isSpecialProperty(java.lang.String name)` Check whether `name` specifies a special property
    `static void` | `restoreSpecialProperties(TestElement testElement, com.thoughtworks.xstream.io.HierarchicalStreamReader reader)` Restore the special properties: TestElement.GUI_CLASS TestElement.TEST_CLASS TestElement.NAME TestElement.ENABLED
    `static void` | `saveSpecialProperties(TestElement testElement, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer)` Save the special properties: TestElement.GUI_CLASS TestElement.TEST_CLASS TestElement.NAME TestElement.ENABLED
    `static void` | `setInVersion(java.lang.String v)`
    `static void` | `setOutVersion(java.lang.String v)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### ATT_CLASS

          public static final java.lang.String ATT_CLASS

      See Also:
        Constant Field Values

    - #### ATT_NAME

          public static final java.lang.String ATT_NAME

      See Also:
        Constant Field Values

    - #### ATT_ELEMENT_TYPE

          public static final java.lang.String ATT_ELEMENT_TYPE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ConversionHelp

          public ConversionHelp()

  - ### Method Detail

    - #### setInVersion

          public static void setInVersion(java.lang.String v)

    - #### setOutVersion

          public static void setOutVersion(java.lang.String v)

    - #### encode

          public static java.lang.String encode(java.lang.String p)

      Encode a string (if necessary) for output to a JTL file. Strings are only encoded if the output version is 1.0, but nulls are always converted to the empty string.
      Parameters:
        `p` - string to encode
      Returns:
        encoded string (will never be null)

    - #### decode

          public static java.lang.String decode(java.lang.String p)

      Decode a string if `inVersion` equals `1.0`
      Parameters:
        `p` - the string to be decoded
      Returns:
        the newly decoded string

    - #### cdata

          public static java.lang.String cdata(byte[] chars,
                                               java.lang.String encoding)
                                        throws java.io.UnsupportedEncodingException

      Embed an array of bytes as a string with `encoding` in a xml-cdata section
      Parameters:
        `chars` - bytes to be encoded and embedded
        `encoding` - the encoding to be used
      Returns:
        the encoded string embedded in a xml-cdata section
      Throws:
        `java.io.UnsupportedEncodingException` - when the bytes can not be encoded using `encoding`

    - #### isSpecialProperty

          public static boolean isSpecialProperty(java.lang.String name)

      Check whether `name` specifies a special property
      Parameters:
        `name` - the name of the property to be checked
      Returns:
        `true` if `name` is the name of a special property

    - #### getPropertyName

          public static java.lang.String getPropertyName(com.thoughtworks.xstream.io.HierarchicalStreamReader reader,
                                                         com.thoughtworks.xstream.converters.UnmarshallingContext context)

      Get the property name, updating it if necessary using `NameUpdater`.
      Parameters:
        `reader` - where to read the name attribute
        `context` - the unmarshalling context
      Returns:
        the property name, may be null if the property has been deleted.
      See Also:
        `getUpgradePropertyName(String, UnmarshallingContext)`

    - #### getPropertyValue

          public static java.lang.String getPropertyValue(com.thoughtworks.xstream.io.HierarchicalStreamReader reader,
                                                          com.thoughtworks.xstream.converters.UnmarshallingContext context,
                                                          java.lang.String name)

      Get the property value, updating it if necessary using `NameUpdater`. Do not use for GUI_CLASS or TEST_CLASS.
      Parameters:
        `reader` - where to read the value
        `context` - the unmarshalling context
        `name` - the name of the property
      Returns:
        the property value, updated if necessary.
      See Also:
        `getUpgradePropertyValue(String, String, UnmarshallingContext)`

    - #### getUpgradePropertyName

          public static java.lang.String getUpgradePropertyName(java.lang.String name,
                                                                com.thoughtworks.xstream.converters.UnmarshallingContext context)

      Update a property name using `NameUpdater`.
      Parameters:
        `name` - the original property name
        `context` - the unmarshalling context
      Returns:
        the property name, may be null if the property has been deleted.

    - #### getUpgradePropertyValue

          public static java.lang.String getUpgradePropertyValue(java.lang.String name,
                                                                 java.lang.String value,
                                                                 com.thoughtworks.xstream.converters.UnmarshallingContext context)

      Update a property value using `NameUpdater.getCurrentName(String, String, String)`. Do not use for GUI_CLASS or TEST_CLASS.
      Parameters:
        `name` - the original property name
        `value` - the original property value
        `context` - the unmarshalling context
      Returns:
        the property value, updated if necessary

    - #### saveSpecialProperties

          public static void saveSpecialProperties(TestElement testElement,
                                                   com.thoughtworks.xstream.io.HierarchicalStreamWriter writer)

      Save the special properties:
      - TestElement.GUI_CLASS
      - TestElement.TEST_CLASS
      - TestElement.NAME
      - TestElement.ENABLED
      Parameters:
        `testElement` - element for which the special properties should be saved
        `writer` - `HierarchicalStreamWriter` in which the special properties should be saved

    - #### restoreSpecialProperties

          public static void restoreSpecialProperties(TestElement testElement,
                                                      com.thoughtworks.xstream.io.HierarchicalStreamReader reader)

      Restore the special properties:
      - TestElement.GUI_CLASS
      - TestElement.TEST_CLASS
      - TestElement.NAME
      - TestElement.ENABLED
      Parameters:
        `testElement` - in which the special properties should be restored
        `reader` - `HierarchicalStreamReader` from which the special properties should be restored

Copyright © 1998-2019 Apache Software Foundation. All Rights Reserved.