Class RawType
java.lang.Object
com.evolveum.prism.xml.ns._public.types_3.RawType
- All Implemented Interfaces:
PlainStructured
,PlainStructured.WithoutStrategy
,JaxbVisitable
,PrismContextSensitive
,Revivable
,ShortDumpable
,Serializable
,Cloneable
public class RawType
extends Object
implements PlainStructured.WithoutStrategy, JaxbVisitable, Revivable, ShortDumpable, 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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.evolveum.midpoint.prism.binding.PlainStructured
PlainStructured.WithoutStrategy
-
Constructor Summary
ConstructorDescriptionRawType
(PrismContext prismContext) RawType
(PrismValue parsed, QName explicitTypeName, @NotNull PrismContext prismContext) RawType
(XNode node, @NotNull PrismContext prismContext) -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(JaxbVisitor visitor) clone()
static RawType
create
(XNode node, PrismContext prismContext) static RawType
create
(String value, PrismContext prismContext) boolean
boolean
equals
(Object that, StructuredEqualsStrategy equalsStrategy) TEMPORARY.extractString
(String defaultValue) static RawType
fromPropertyRealValue
(Object realValue, QName explicitTypeName, @NotNull PrismContext prismContext) <IV extends PrismValue,
ID extends ItemDefinition<?>>
Item<IV,ID> getParsedItem
(ID itemDefinition) <IV extends PrismValue,
ID extends ItemDefinition<?>>
Item<IV,ID> getParsedItem
(ID itemDefinition, QName itemName) <T> T
getParsedRealValue
(@NotNull Class<T> clazz) <V> V
getParsedRealValue
(ItemDefinition<?> itemDefinition, ItemPath itemPath) <IV extends PrismValue>
IVgetParsedValue
(@Nullable ItemDefinition<?> itemDefinition, @Nullable QName itemName) @NotNull RootXNode
getRootXNode
(@NotNull QName itemName) getValue()
getValue
(boolean store) Extracts a "real value" fromRawType
object without expecting any specific type beforehand.static Object
Extracts a "real value" from a potentialRawType
object without expecting any specific type beforehand.getXnode()
int
hashCode()
int
hashCode
(StructuredHashCodeStrategy strategy) boolean
isParsed()
void
revive
(PrismContext prismContext) TODO: Is revive necessary if prism context is static? TODO document (if it's found to be necessary)This method always returns a mutable XNode.void
setRawValue
(XNode replacement) Sets the new raw content, defined by an XNode.void
Show the content of the object intended for diagnostics.toString()
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.evolveum.midpoint.util.ShortDumpable
shortDump, shortDumpLazily
-
Constructor Details
-
RawType
-
RawType
-
RawType
public RawType(PrismValue parsed, QName explicitTypeName, @NotNull @NotNull PrismContext prismContext)
-
-
Method Details
-
fromPropertyRealValue
public static RawType fromPropertyRealValue(Object realValue, QName explicitTypeName, @NotNull @NotNull PrismContext prismContext) -
getValue
Extracts a "real value" from a potentialRawType
object without expecting any specific type beforehand. (Useful e.g. for determining value of xsd:anyType XML property.)- Throws:
SchemaException
-
getValue
- Throws:
SchemaException
-
getValue
Extracts a "real value" fromRawType
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
TEMPORARY. EXPERIMENTAL. DO NOT USE. -
extractString
-
revive
Description copied from interface:Revivable
TODO: Is revive necessary if prism context is static? TODO document (if it's found to be necessary) -
getXnode
-
getRootXNode
-
getPrismContext
- Specified by:
getPrismContext
in interfacePrismContextSensitive
-
getExplicitTypeName
-
getParsedValue
public <IV extends PrismValue> IV getParsedValue(@Nullable @Nullable ItemDefinition<?> itemDefinition, @Nullable @Nullable QName itemName) throws SchemaException - Throws:
SchemaException
-
getParsedRealValue
public <V> V getParsedRealValue(ItemDefinition<?> itemDefinition, ItemPath itemPath) throws SchemaException - Throws:
SchemaException
-
getAlreadyParsedValue
-
getParsedRealValue
- Throws:
SchemaException
-
getParsedItem
public <IV extends PrismValue,ID extends ItemDefinition<?>> Item<IV,ID> getParsedItem(ID itemDefinition) throws SchemaException - Throws:
SchemaException
-
getParsedItem
public <IV extends PrismValue,ID extends ItemDefinition<?>> Item<IV,ID> getParsedItem(ID itemDefinition, QName itemName) throws SchemaException - Throws:
SchemaException
-
serializeToXNode
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
-
serializeToXNode
- Throws:
SchemaException
-
clone
- Specified by:
clone
in interfacePlainStructured
- Overrides:
clone
in classObject
-
hashCode
- Specified by:
hashCode
in interfacePlainStructured
- Specified by:
hashCode
in interfacePlainStructured.WithoutStrategy
-
hashCode
public int hashCode() -
equals
-
equals
- Specified by:
equals
in interfacePlainStructured
- Specified by:
equals
in interfacePlainStructured.WithoutStrategy
-
create
-
create
-
toString
-
shortDump
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 interfaceShortDumpable
- 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() -
guessFormattedValue
- Throws:
SchemaException
-
accept
- Specified by:
accept
in interfaceJaxbVisitable
-
setRawValue
Sets the new raw content, defined by an XNode. The value must be immutable. Experimental. Use with the greatest care.
-