Package org.osgi.dto

Class DTO


  • public abstract class DTO
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      private static int MAX_LENGTH  
    • Constructor Summary

      Constructors 
      Constructor Description
      DTO()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.StringBuilder appendArray​(java.lang.StringBuilder result, java.util.Map<java.lang.Object,​java.lang.String> objectRefs, java.lang.String refpath, java.lang.Object array)
      Append the specified array's string representation to the specified StringBuilder.
      private static java.lang.StringBuilder appendDTO​(java.lang.StringBuilder result, java.util.Map<java.lang.Object,​java.lang.String> objectRefs, java.lang.String refpath, DTO dto)
      Append the specified DTO's string representation to the specified StringBuilder.
      private static java.lang.StringBuilder appendIterable​(java.lang.StringBuilder result, java.util.Map<java.lang.Object,​java.lang.String> objectRefs, java.lang.String refpath, java.lang.Iterable<?> iterable)
      Append the specified iterable's string representation to the specified StringBuilder.
      private static java.lang.StringBuilder appendMap​(java.lang.StringBuilder result, java.util.Map<java.lang.Object,​java.lang.String> objectRefs, java.lang.String refpath, java.util.Map<?,​?> map)
      Append the specified map's string representation to the specified StringBuilder.
      private static java.lang.StringBuilder appendString​(java.lang.StringBuilder result, java.lang.CharSequence string)
      Append the specified string to the specified StringBuilder.
      private static java.lang.StringBuilder appendValue​(java.lang.StringBuilder result, java.util.Map<java.lang.Object,​java.lang.String> objectRefs, java.lang.String refpath, java.lang.Object value)
      Append the specified value's string representation to the specified StringBuilder.
      private static java.lang.CharSequence compress​(java.lang.CharSequence in)
      Compress, in length, the specified string.
      java.lang.String toString()
      Return a string representation of this DTO suitable for use when debugging.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DTO

        public DTO()
    • Method Detail

      • toString

        public java.lang.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 java.lang.Object
        Returns:
        A string representation of this DTO suitable for use when debugging.
      • appendDTO

        private static java.lang.StringBuilder appendDTO​(java.lang.StringBuilder result,
                                                         java.util.Map<java.lang.Object,​java.lang.String> objectRefs,
                                                         java.lang.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 java.lang.StringBuilder appendValue​(java.lang.StringBuilder result,
                                                           java.util.Map<java.lang.Object,​java.lang.String> objectRefs,
                                                           java.lang.String refpath,
                                                           java.lang.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 java.lang.StringBuilder appendArray​(java.lang.StringBuilder result,
                                                           java.util.Map<java.lang.Object,​java.lang.String> objectRefs,
                                                           java.lang.String refpath,
                                                           java.lang.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 java.lang.StringBuilder appendIterable​(java.lang.StringBuilder result,
                                                              java.util.Map<java.lang.Object,​java.lang.String> objectRefs,
                                                              java.lang.String refpath,
                                                              java.lang.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 java.lang.StringBuilder appendMap​(java.lang.StringBuilder result,
                                                         java.util.Map<java.lang.Object,​java.lang.String> objectRefs,
                                                         java.lang.String refpath,
                                                         java.util.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 java.lang.StringBuilder appendString​(java.lang.StringBuilder result,
                                                            java.lang.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 java.lang.CharSequence compress​(java.lang.CharSequence in)
        Compress, in length, the specified string.
        Parameters:
        in - The string to potentially compress.
        Returns:
        The string compressed, if necessary.