Class RawType
- java.lang.Object
-
- com.evolveum.prism.xml.ns._public.types_3.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
-
-
Constructor Summary
Constructors Constructor Description RawType(PrismContext prismContext)
RawType(PrismValue parsed, QName explicitTypeName, @NotNull PrismContext prismContext)
RawType(XNode node, @NotNull PrismContext prismContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(JaxbVisitor visitor)
RawType
clone()
static RawType
create(XNode node, PrismContext prismContext)
static RawType
create(String value, PrismContext prismContext)
boolean
equals(Object obj)
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)
String
extractString()
TEMPORARY.String
extractString(String defaultValue)
static RawType
fromPropertyRealValue(Object realValue, QName explicitTypeName, @NotNull PrismContext prismContext)
PrismValue
getAlreadyParsedValue()
QName
getExplicitTypeName()
<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)
PrismContext
getPrismContext()
@NotNull RootXNode
getRootXNode(@NotNull QName itemName)
Object
getValue()
Object
getValue(boolean store)
Extracts a "real value" from RawType object without expecting any specific type beforehand.static Object
getValue(Object value)
Extracts a "real value" from a potential RawType object without expecting any specific type beforehand.XNode
getXnode()
String
guessFormattedValue()
int
hashCode()
boolean
isParsed()
void
revive(PrismContext prismContext)
XNode
serializeToXNode()
This method always returns a mutable XNode.XNode
serializeToXNode(SerializationContext sc)
void
setRawValue(XNode replacement)
Sets the new raw content, defined by an XNode.void
shortDump(StringBuilder sb)
Show the content of the object intended for diagnostics.String
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 Detail
-
RawType
public RawType(PrismContext prismContext)
-
RawType
public RawType(XNode node, @NotNull @NotNull PrismContext prismContext)
-
RawType
public RawType(PrismValue parsed, QName explicitTypeName, @NotNull @NotNull PrismContext prismContext)
-
-
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() throws SchemaException
- 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.
-
revive
public void revive(PrismContext prismContext) throws SchemaException
- Specified by:
revive
in interfaceRevivable
- Throws:
SchemaException
-
getXnode
public XNode getXnode()
-
getPrismContext
public PrismContext getPrismContext()
- Specified by:
getPrismContext
in interfacePrismContextSensitive
-
getExplicitTypeName
public QName 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
public PrismValue getAlreadyParsedValue()
-
getParsedRealValue
public <T> T getParsedRealValue(@NotNull @NotNull Class<T> clazz) throws SchemaException
- 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
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
-
serializeToXNode
public XNode serializeToXNode(SerializationContext sc) throws SchemaException
- Throws:
SchemaException
-
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 interfaceorg.jvnet.jaxb2_commons.lang.Equals
-
create
public static RawType create(String value, PrismContext prismContext)
-
create
public static RawType create(XNode node, PrismContext prismContext)
-
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 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
public String guessFormattedValue() throws SchemaException
- Throws:
SchemaException
-
accept
public void accept(JaxbVisitor visitor)
- Specified by:
accept
in interfaceJaxbVisitable
-
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.
-
-