Package wt.ixb.impl.jaxb
Class JAXBUtil
java.lang.Object
wt.ixb.impl.jaxb.JAXBUtil
This class provides methods for operation on JAXB objects, includes: set/get attributes of JAXB object set necessary
attributes value for describe element marshall the JAXB object
Supported API: true
Extendable: false
Supported API: true
Extendable: false
-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringbuild key by id and kind
Supported API: truestatic StringconcatString(Object... strings) concat string by StringBuilder
Supported API: truestatic ObjectconstructRealValue(String key, String seperator, Object realValue, Object oldValue) construct value for mapped attribute
Supported API: truegetElementListFromMap(Map<String, Map<String, List<Object>>> valueMap, String elementName, String attributeKey) get list from map, will create one if not found.getElementListFromMapForRead(Map<String, Map<String, List<Object>>> rootValueMap, Map<String, Map<String, List<Object>>> valueMap, String elementName, String attributeKey, Object contextObject) get list from map, will create one if not found.static Stringget id of the jaxb object, will generate one and set if no id is defined for the jaxb object
Supported API: truestatic Stringget id of the jaxb object, will generate one and set if no id is defined for the jaxb object
Supported API: truestatic String[]getKeyAndValue(String str, String defaultValue, String prefix) parse string to key and value, also replace some pre-defined variables
Supported API: truestatic ObjectgetObjectValue(String formatType, Object rootObject, String value) get object value
Supported API: truestatic ObjectgetObjectValue(String formatType, Object rootObject, String value, String tagName, boolean getAsMultiple) get object value
Supported API: truestatic String[]getPropOrder(Object rootObject) get PropOrder of XmlType annotation by object
Supported API: truegetRequiredAttributes(String type, String requiredAttributes) get root tag required attributes by format type, we will use it init root element during marshall
Supported API: truestatic StringgetTagNameById(String id) try to get windchill tag name by the id (localID or ufid)
Supported API: truestatic StringgetTagNameById(String format, Object object) try to get windchill tag name by the object
Supported API: truestatic StringgetTagNameById(String format, Object object, Object parentObj) try to get windchill tag name by the object and parent object (if existed)
Supported API: truestatic StringgetTagNameById(String format, Object object, Object parentObj, boolean throwException) try to get windchill tag name by the object and parent object (if existed)
Supported API: truestatic StringgetValidJavaTypeName(String tagName) change xmlTagName into valid Java Type Name
Supported API: truegetValueMap(String seperator, Object oldValue) convert key-value pair string into map
Supported API: truestatic ObjectgetValueSpecially(IxbJaxbElement rootElement, String key) get value from jaxb specially, corresponding to setValueSpecially
Supported API: truestatic ObjectgetValueSpecially(IxbJaxbElement rootElement, String key, String orginalKey) get value from jaxb specially, corresponding to setValueSpecially
Supported API: truestatic ObjectgetValueSpecially(IxbJaxbElement rootElement, String key, String orginalKey, boolean getAsList) get value from jaxb specially, corresponding to setValueSpecially
Supported API: truestatic QNamegetXmlTagName(Class<?> clazz) get QName of XmlType annotation by class
Supported API: truestatic QNamegetXmlTagName(Class<?> clazz, boolean throwException) get QName of XmlType annotation by class
Supported API: truestatic QNamegetXmlTagName(Object rootObject) get QName of XmlType annotation by object
Supported API: truestatic QNamegetXmlTagName(Object rootObject, boolean throwException) get QName of XmlType annotation by object
Supported API: truestatic booleanisDescribeTagName(String format, String tagName) check if the element name is a describe element tag
Supported API: truestatic booleanisSupportedCoreTag(String format, String tagName) check if the element name is a valid element tag
Supported API: truestatic booleanisSupportedWNCTag(String format, String tagName) check if the element name is a valid Windchill element tag
Supported API: truestatic booleanisValidSpecialElement(String type, String elementName) check if the mapped element name is valid and special one (contains '||')
Supported API: truestatic booleanisWNCLinkCoreTag(String format, String tagName) check if the element name is a link element tag
Supported API: truestatic voidnormalize the node, add xil:nil=true to the ref element
Supported API: truestatic Stringnormalize the string and set it as id or ref.static voidrealMarshall(String type, javax.xml.bind.Marshaller marshaller, Node header, Object o) marshall the jaxb object
Supported API: truestatic voidremoveNilAttribute(Node header) remove xil:nil=true attribute during import process.static ObjectresolveValue(String value, IxbJaxbElement rootElement) resolve object value like {ROOT}/number
Supported API: truestatic voidsetIdIfNeeded(String format, String tagName, Object object, IxbJaxbElement element) set id if we can't find one.static voidsetIdIfNeeded(String format, String tagName, String idPrefix, Object object) set id if we can't find one.static voidset object value
Supported API: truestatic voidsetObjectValue(String type, Object rootObject, String prefix, String key, Object value, boolean alwaysAdd) set object value
Supported API: truestatic voidsetObjectValue(String type, Object rootObject, String prefix, String key, Object value, boolean alwaysAdd, String xmlTagNameToCreateJAXBElement) set object value
Supported API: truestatic voidsetValueSpecially(IxbJaxbElement rootElement, String key, Object realValue) set value to jaxb specially, may create outer element and add it in RootChildrenMap
Supported API: truestatic voidsetValueSpecially(IxbJaxbElement rootElement, String key, Object realValue, String orginalKey) set value to jaxb specially, may create outer element and add it in RootChildrenMap
Supported API: truestatic voidsetValueSpecially(IxbJaxbElement rootElement, String key, Object realValue, String orginalKey, boolean alwaysAdd) set value to jaxb specially, may create outer element and add it in RootChildrenMap
Supported API: truestatic StringxmlTagNameToClassName(String tagName) change xmlTagName into valid Class name
Supported API: true
-
Method Details
-
getXmlTagName
get QName of XmlType annotation by object
Supported API: true- Parameters:
rootObject- the jaxb object- Returns:
- qname
- Throws:
WTException
-
getXmlTagName
get QName of XmlType annotation by object
Supported API: true- Parameters:
rootObject- the jaxb objectthrowException- which to throw exception if not found- Returns:
- qname
- Throws:
WTException
-
getXmlTagName
get QName of XmlType annotation by class
Supported API: true- Parameters:
rootObject- the jaxb object- Returns:
- qname
- Throws:
WTException
-
getXmlTagName
get QName of XmlType annotation by class
Supported API: true- Parameters:
rootObject- the jaxb objectthrowException- which to throw exception if not found- Returns:
- qname
- Throws:
WTException
-
getPropOrder
get PropOrder of XmlType annotation by object
Supported API: true- Parameters:
rootObject- the jaxb object- Returns:
- PropOrder
- Throws:
WTException
-
setObjectValue
public static void setObjectValue(String type, Object rootObject, String prefix, String key, Object value) throws Exception set object value
Supported API: true- Parameters:
format- format typerootObject- jaxb objectprefix- root element namekey- element name with '/' as seperatorvalue- value to be set- Throws:
Exception- ,wt.util.WTException
-
setObjectValue
public static void setObjectValue(String type, Object rootObject, String prefix, String key, Object value, boolean alwaysAdd) throws Exception, WTException set object value
Supported API: true- Parameters:
format- format typerootObject- jaxb objectprefix- root element namekey- element name with '/' as seperatorvalue- value to be setalwaysAdd- should be always added or replace old one- Throws:
Exception- ,wt.util.WTExceptionWTException
-
setObjectValue
public static void setObjectValue(String type, Object rootObject, String prefix, String key, Object value, boolean alwaysAdd, String xmlTagNameToCreateJAXBElement) throws Exception, WTException set object value
Supported API: true- Parameters:
format- format typerootObject- jaxb objectprefix- root element namekey- element name with '/' as seperatorvalue- value to be setalwaysAdd- should be always added or replace old one- Throws:
Exception- ,wt.util.WTExceptionWTException
-
normalizeStringForId
normalize the string and set it as id or ref.
Supported API: true- Parameters:
str-- Returns:
- string
-
getObjectValue
public static Object getObjectValue(String formatType, Object rootObject, String value) throws Exception get object value
Supported API: true -
getObjectValue
public static Object getObjectValue(String formatType, Object rootObject, String value, String tagName, boolean getAsMultiple) throws Exception get object value
Supported API: true- Parameters:
rootObject- jaxb objectvalue- element name with '/' as seperator- Returns:
- object
- Throws:
Exception- ,wt.util.WTException
-
xmlTagNameToClassName
change xmlTagName into valid Class name
Supported API: true- Parameters:
tagName- orginal tagName- Returns:
- className
-
getValidJavaTypeName
change xmlTagName into valid Java Type Name
Supported API: true- Parameters:
tagName- orginal tagName- Returns:
- JavaTypeName
-
constructRealValue
public static Object constructRealValue(String key, String seperator, Object realValue, Object oldValue) construct value for mapped attribute
Supported API: true- Parameters:
key- key nameseperator- seperatorrealValue- valueoldValue- old key-value pair string- Returns:
- JavaTypeName
-
getValueMap
convert key-value pair string into map
Supported API: true- Parameters:
seperator- seperatoroldValue- old key-value pair string- Returns:
- map
-
realMarshall
public static void realMarshall(String type, javax.xml.bind.Marshaller marshaller, Node header, Object o) throws WTException, Exception, javax.xml.bind.JAXBException marshall the jaxb object
Supported API: true- Parameters:
type- format typemarshaller- marshaller instanceheader- the DOM node used to marshallo- the jaxb object- Throws:
Exception- , wt.util.WTException, javax.xml.bind.JAXBExceptionWTExceptionjavax.xml.bind.JAXBException
-
normalize
normalize the node, add xil:nil=true to the ref element
Supported API: true- Parameters:
header- DOM nodedoc- document of the DOM nodestoreInCData- if need to store key-value pair in CData mode, not used nowformatType- format type- Throws:
WTException
-
isSupportedWNCTag
check if the element name is a valid Windchill element tag
Supported API: true- Parameters:
format- format typetagName- tag name- Returns:
- boolean
- Throws:
WTException
-
isSupportedCoreTag
check if the element name is a valid element tag
Supported API: true- Parameters:
format- format typetagName- tag name- Returns:
- boolean
- Throws:
WTException
-
isWNCLinkCoreTag
check if the element name is a link element tag
Supported API: true- Parameters:
format- format typetagName- tag name- Returns:
- boolean
- Throws:
WTException
-
isDescribeTagName
check if the element name is a describe element tag
Supported API: true- Parameters:
format- format typetagName- tag name- Returns:
- boolean
- Throws:
WTException
-
getTagNameById
try to get windchill tag name by the object
Supported API: true- Parameters:
format- format typeobject- jaxb object- Returns:
- tag name
- Throws:
WTException
-
getTagNameById
public static String getTagNameById(String format, Object object, Object parentObj) throws WTException try to get windchill tag name by the object and parent object (if existed)
Supported API: true- Parameters:
format- format typeobject- jaxb objectparentObj- parent jaxb object- Returns:
- tag name
- Throws:
WTException
-
getTagNameById
public static String getTagNameById(String format, Object object, Object parentObj, boolean throwException) throws WTException try to get windchill tag name by the object and parent object (if existed)
Supported API: true- Parameters:
format- format typeobject- jaxb objectparentObj- parent jaxb objectthrowException- need to throw Exception- Returns:
- tag name
- Throws:
WTException
-
getTagNameById
try to get windchill tag name by the id (localID or ufid)
Supported API: true- Parameters:
id-- Returns:
- tag name
-
setIdIfNeeded
public static void setIdIfNeeded(String format, String tagName, Object object, IxbJaxbElement element) throws WTException set id if we can't find one.
Supported API: true- Parameters:
format- format typetagName- tag name of the jaxb objectobject- jaxb obejct- Throws:
WTException
-
setIdIfNeeded
public static void setIdIfNeeded(String format, String tagName, String idPrefix, Object object) throws WTException set id if we can't find one.
Supported API: true- Parameters:
format- format typetagName- tag name of the jaxb objectidPrefix- used to generate idobject- jaxb obejct- Throws:
WTException
-
getElementListFromMap
public static List<Object> getElementListFromMap(Map<String, Map<String, List<Object>>> valueMap, String elementName, String attributeKey) get list from map, will create one if not found.
Supported API: true- Parameters:
elementName-- Returns:
- list
-
getElementListFromMapForRead
public static List<Object> getElementListFromMapForRead(Map<String, Map<String, List<Object>>> rootValueMap, Map<String, Map<String, List<Object>>> valueMap, String elementName, String attributeKey, Object contextObject) get list from map, will create one if not found.
Supported API: true- Parameters:
elementName-- Returns:
- list
-
buildKey
build key by id and kind
Supported API: true- Parameters:
refId-kind-- Returns:
- key
-
getId
public static String getId(String format, Object rootObject, Object contextObject) throws WTException get id of the jaxb object, will generate one and set if no id is defined for the jaxb object
Supported API: true- Parameters:
format- format typerootObject- jaxb objecttagName- tag name of the jaxb object- Throws:
WTException
-
getId
public static String getId(String format, Object rootObject, String tagName, boolean needSet) throws WTException get id of the jaxb object, will generate one and set if no id is defined for the jaxb object
Supported API: true- Parameters:
format- format typerootObject- jaxb objecttagName- tag name of the jaxb objectneedSet- if need to set id if no id found- Throws:
WTException
-
removeNilAttribute
remove xil:nil=true attribute during import process.
Supported API: true- Parameters:
header-
-
concatString
concat string by StringBuilder
Supported API: true- Parameters:
header-
-
getKeyAndValue
parse string to key and value, also replace some pre-defined variables
Supported API: true- Parameters:
header-
-
isValidSpecialElement
check if the mapped element name is valid and special one (contains '||')
Supported API: true- Parameters:
elementName-- Returns:
- boolean
- Throws:
WTException
-
setValueSpecially
public static void setValueSpecially(IxbJaxbElement rootElement, String key, Object realValue) throws WTException set value to jaxb specially, may create outer element and add it in RootChildrenMap
Supported API: true- Parameters:
rootElement-schemaType-rootObject-- Throws:
WTException
-
setValueSpecially
public static void setValueSpecially(IxbJaxbElement rootElement, String key, Object realValue, String orginalKey) throws WTException set value to jaxb specially, may create outer element and add it in RootChildrenMap
Supported API: true- Parameters:
rootElement-schemaType-rootObject-orginalKey-- Throws:
WTException
-
setValueSpecially
public static void setValueSpecially(IxbJaxbElement rootElement, String key, Object realValue, String orginalKey, boolean alwaysAdd) throws WTException set value to jaxb specially, may create outer element and add it in RootChildrenMap
Supported API: true- Parameters:
rootElement-schemaType-rootObject-orginalKey-- Throws:
WTException
-
getValueSpecially
get value from jaxb specially, corresponding to setValueSpecially
Supported API: true- Parameters:
rootElement-key-- Returns:
- boolean
- Throws:
WTException
-
getValueSpecially
public static Object getValueSpecially(IxbJaxbElement rootElement, String key, String orginalKey) throws WTException get value from jaxb specially, corresponding to setValueSpecially
Supported API: true- Parameters:
rootElement-key-orginalKey-- Returns:
- boolean
- Throws:
WTException
-
getValueSpecially
public static Object getValueSpecially(IxbJaxbElement rootElement, String key, String orginalKey, boolean getAsList) throws WTException get value from jaxb specially, corresponding to setValueSpecially
Supported API: true- Parameters:
rootElement-key-orginalKey-- Returns:
- Throws:
WTException
-
resolveValue
resolve object value like {ROOT}/number
Supported API: true- Parameters:
value-rootElement-- Returns:
- object
- Throws:
WTException
-
getRequiredAttributes
public static List<String> getRequiredAttributes(String type, String requiredAttributes) throws WTException get root tag required attributes by format type, we will use it init root element during marshall
Supported API: true- Parameters:
type- format type- Returns:
- set
- Throws:
WTException
-