Class RawType

  • All Implemented Interfaces:
    JaxbVisitable, PrismContextSensitive, Revivable, ShortDumpable, Serializable, Cloneable, org.jvnet.jaxb2_commons.lang.Equals

    public class RawType
    extends Object
    implements Serializable, Cloneable, org.jvnet.jaxb2_commons.lang.Equals, Revivable, ShortDumpable, JaxbVisitable, PrismContextSensitive
    A class used to hold raw XNodes until the definition for such an object is known. This class should be thread-safe because it is used in shared objects, like cached resources or roles. (See MID-6506.) But by default it is not, as it contains internal state (xnode/parsed) that can lead to race conditions when parsing. In midPoint 4.2 it was made roughly thread-safe by including explicit synchronization at appropriate places. See MID-6542. In midPoint 4.3 following changes were made to address following issues: 1. We need to support freezing the content (embedded xnode/prism value) XNodes are freezable, and RawType requires frozen XNode. 2. We should consider avoiding explicit synchronization for performance reasons Internal structure is State class - State `Parsed` (noop for subsequent parsing calls) - State `Raw` (parsing results in transition to state Parsed) - TODO what about `Transient`? Implementation has stable Equals, but hashcode is unstable since it would require significant effort to unify XNode and parsed items hashcode computation.
    See Also:
    Serialized Form
    • Method Detail

      • fromPropertyRealValue

        public static RawType fromPropertyRealValue​(Object realValue,
                                                    QName explicitTypeName,
                                                    @NotNull
                                                    @NotNull PrismContext prismContext)
      • getValue

        public static Object getValue​(Object value)
                               throws SchemaException
        Extracts a "real value" from a potential RawType object without expecting any specific type beforehand. (Useful e.g. for determining value of xsd:anyType XML property.)
        Throws:
        SchemaException
      • getValue

        public Object getValue​(boolean store)
                        throws SchemaException
        Extracts a "real value" from RawType object without expecting any specific type beforehand. If no explicit type is present, assumes xsd:string (and fails if the content is structured).
        Throws:
        SchemaException
      • extractString

        @Experimental
        public String extractString()
        TEMPORARY. EXPERIMENTAL. DO NOT USE.
      • extractString

        public String extractString​(String defaultValue)
      • getXnode

        public XNode getXnode()
      • getRootXNode

        @NotNull
        public @NotNull RootXNode getRootXNode​(@NotNull
                                               @NotNull QName itemName)
      • getExplicitTypeName

        public QName getExplicitTypeName()
      • getAlreadyParsedValue

        public PrismValue getAlreadyParsedValue()
      • serializeToXNode

        public XNode serializeToXNode()
                               throws SchemaException
        This method always returns a mutable XNode. For example, the serializer sometimes needs to set type QName on the returned XNode. (The cloning might be an overkill, harming the performance. This will be resolved later, if needed.)
        Throws:
        SchemaException
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • equals

        public boolean equals​(org.jvnet.jaxb2_commons.locator.ObjectLocator thisLocator,
                              org.jvnet.jaxb2_commons.locator.ObjectLocator thatLocator,
                              Object that,
                              org.jvnet.jaxb2_commons.lang.EqualsStrategy equalsStrategy)
        Specified by:
        equals in interface org.jvnet.jaxb2_commons.lang.Equals
      • shortDump

        public void shortDump​(StringBuilder sb)
        Description copied from interface: ShortDumpable
        Show the content of the object intended for diagnostics. This method is supposed to append a compact, human-readable output in a single line. Unlike toString() method, there is no requirement to identify the actual class or type of the object. It is assumed that the class/type will be obvious from the context in which the output is used.
        Specified by:
        shortDump in interface ShortDumpable
        Parameters:
        sb - StringBuilder to which to a compact one-line content of the object intended for diagnostics by system administrator should be appended.
      • isParsed

        public boolean isParsed()
      • setRawValue

        @Experimental
        public void setRawValue​(XNode replacement)
        Sets the new raw content, defined by an XNode. The value must be immutable. Experimental. Use with the greatest care.