Package org.osgi.dto

Class DTO

java.lang.Object
org.osgi.dto.DTO
Direct Known Subclasses:
BundleDTO, BundleStartLevelDTO, BundleWiringDTO, CapabilityDTO, CapabilityRefDTO, FrameworkDTO, FrameworkStartLevelDTO, FrameworkWiringDTO, RequirementDTO, RequirementRefDTO, ResourceDTO, ServiceReferenceDTO, WireDTO, WiringDTO

public abstract class DTO extends Object
Super type for Data Transfer Objects.

A Data Transfer Object (DTO) is easily serializable having only public fields of primitive types and their wrapper classes, String, enums, Version, and DTOs. List, Set, Map, and array aggregates may also be used. The aggregates must only hold objects of the listed types or aggregates. The types for Map keys are limited to primitive wrapper classes, String, enums, and Version.

The object graph from a Data Transfer Object must be a tree to simplify serialization and deserialization.

  • Field Details

  • Constructor Details

    • DTO

      public DTO()
  • Method Details

    • toString

      public String toString()
      Return a string representation of this DTO suitable for use when debugging.

      The format of the string representation is not specified and subject to change.

      Overrides:
      toString in class Object
      Returns:
      A string representation of this DTO suitable for use when debugging.
    • appendDTO

      private static StringBuilder appendDTO(StringBuilder result, Map<Object,String> objectRefs, String refpath, DTO dto)
      Append the specified DTO's string representation to the specified StringBuilder.
      Parameters:
      result - StringBuilder to which the string representation is appended.
      objectRefs - References to "seen" objects.
      refpath - The reference path of the specified DTO.
      dto - The DTO whose string representation is to be appended.
      Returns:
      The specified StringBuilder.
    • appendValue

      private static StringBuilder appendValue(StringBuilder result, Map<Object,String> objectRefs, String refpath, Object value)
      Append the specified value's string representation to the specified StringBuilder.

      This method handles cycles in the object graph, using path-based references, even though the specification requires the object graph from a DTO to be a tree.

      Parameters:
      result - StringBuilder to which the string representation is appended.
      objectRefs - References to "seen" objects.
      refpath - The reference path of the specified value.
      value - The object whose string representation is to be appended.
      Returns:
      The specified StringBuilder.
    • appendArray

      private static StringBuilder appendArray(StringBuilder result, Map<Object,String> objectRefs, String refpath, Object array)
      Append the specified array's string representation to the specified StringBuilder.
      Parameters:
      result - StringBuilder to which the string representation is appended.
      objectRefs - References to "seen" objects.
      refpath - The reference path of the specified array.
      array - The array whose string representation is to be appended.
      Returns:
      The specified StringBuilder.
    • appendIterable

      private static StringBuilder appendIterable(StringBuilder result, Map<Object,String> objectRefs, String refpath, Iterable<?> iterable)
      Append the specified iterable's string representation to the specified StringBuilder.
      Parameters:
      result - StringBuilder to which the string representation is appended.
      objectRefs - References to "seen" objects.
      refpath - The reference path of the specified list.
      iterable - The iterable whose string representation is to be appended.
      Returns:
      The specified StringBuilder.
    • appendMap

      private static StringBuilder appendMap(StringBuilder result, Map<Object,String> objectRefs, String refpath, Map<?,?> map)
      Append the specified map's string representation to the specified StringBuilder.
      Parameters:
      result - StringBuilder to which the string representation is appended.
      objectRefs - References to "seen" objects.
      refpath - The reference path of the specified map.
      map - The map whose string representation is to be appended.
      Returns:
      The specified StringBuilder.
    • appendString

      private static StringBuilder appendString(StringBuilder result, CharSequence string)
      Append the specified string to the specified StringBuilder.
      Parameters:
      result - StringBuilder to which the string is appended.
      string - The string to be appended.
      Returns:
      The specified StringBuilder.
    • compress

      private static CharSequence compress(CharSequence in)
      Compress, in length, the specified string.
      Parameters:
      in - The string to potentially compress.
      Returns:
      The string compressed, if necessary.