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 voidaccept(JaxbVisitor visitor)RawTypeclone()static RawTypecreate(XNode node, PrismContext prismContext)static RawTypecreate(String value, PrismContext prismContext)booleanequals(Object obj)booleanequals(org.jvnet.jaxb2_commons.locator.ObjectLocator thisLocator, org.jvnet.jaxb2_commons.locator.ObjectLocator thatLocator, Object that, org.jvnet.jaxb2_commons.lang.EqualsStrategy equalsStrategy)StringextractString()TEMPORARY.StringextractString(String defaultValue)static RawTypefromPropertyRealValue(Object realValue, QName explicitTypeName, @NotNull PrismContext prismContext)PrismValuegetAlreadyParsedValue()QNamegetExplicitTypeName()<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> TgetParsedRealValue(@NotNull Class<T> clazz)<V> VgetParsedRealValue(ItemDefinition<?> itemDefinition, ItemPath itemPath)<IV extends PrismValue>
IVgetParsedValue(@Nullable ItemDefinition<?> itemDefinition, @Nullable QName itemName)PrismContextgetPrismContext()@NotNull RootXNodegetRootXNode(@NotNull QName itemName)ObjectgetValue()ObjectgetValue(boolean store)Extracts a "real value" from RawType object without expecting any specific type beforehand.static ObjectgetValue(Object value)Extracts a "real value" from a potential RawType object without expecting any specific type beforehand.XNodegetXnode()StringguessFormattedValue()inthashCode()booleanisParsed()voidrevive(PrismContext prismContext)XNodeserializeToXNode()This method always returns a mutable XNode.XNodeserializeToXNode(SerializationContext sc)voidsetRawValue(XNode replacement)Sets the new raw content, defined by an XNode.voidshortDump(StringBuilder sb)Show the content of the object intended for diagnostics.StringtoString()-
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:
revivein interfaceRevivable- Throws:
SchemaException
-
getXnode
public XNode getXnode()
-
getPrismContext
public PrismContext getPrismContext()
- Specified by:
getPrismContextin 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:
equalsin 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:ShortDumpableShow 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:
shortDumpin 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:
acceptin 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.
-
-