public class AppianTypeFactory extends Object
newInstance(com.appiancorp.suiteapi.type.TypeService)
of this class,
then it can be used to read and create TypedValues, build CDTs from scratch, etc.
Reading a data subset
TypeService ts = ... TypedValue tv = ... AppianTypeFactory tf = AppianTypeFactory.newInstance(ts); AppianObject datasubset = (AppianObject) tf.toAppianElement(tv); long startIndex = datasubset.getPrimitive("startIndex").getLong(); long batchSize = datasubset.getPrimitive("batchSize").getLong(); AppianList data = datasubset.getList("data"); for (AppianObject row : data.toArray(new AppianObject[] {})) { long id = row.getPrimitive("id").getLong(); String name = row.getPrimitive("name").getString(); }
Converting to a TypedValue
TypeService ts = ... AppianElement element = ... AppianTypeFactory tf = AppianTypeFactory.newInstance(ts); TypedValue tv = tf.toTypedValue(element);
Creating a list from scratch
AppianList values = tf.createList(AppianType.STRING); values.add(tf.createString("Hello")); values.add(tf.createString("World!"));
Create a CDT from scratch
Datatype type = ts.getTypeByQualifiedName(new QName("urn:appian:acme", "project")); AppianObject project = (AppianObject) tf.createElement(type.getId()); project.put("name", tf.createString("My First Project")); project.put("isComplete", tf.createBoolean(true));
Creating a dictionary
AppianObject dictionary = (AppianObject) tf.createElement(AppianType.DICTIONARY); dictionary.put("name", tf.createString("My First Project")); dictionary.put("isComplete", tf.createBoolean(true));
Converting a TypedValue object to Java Object
TypedValue tv = ... Customer customer = (AppianObject) tf.toJavaObject(tv, Customer.class); String name = customer.getName(); Date date = customer.getJoinedDate();
Modifier and Type | Method and Description |
---|---|
AppianPrimitive |
createBoolean(Boolean value)
Creates a boolean with the given value
|
AppianPrimitive |
createDate(Date value)
Creates a date with the given value
|
AppianPrimitive |
createDateTime(Timestamp value)
Creates a date and time with the given value
|
AppianPrimitive |
createDouble(Double value)
Creates a double with the given value
|
AppianElement |
createElement(long typeId)
Creates a new element of the given type.
|
AppianList |
createList(long typeId)
Creates a list of the given type.
|
AppianPrimitive |
createLong(Long value)
Creates a long with the given value
|
AppianPrimitive |
createString(String value)
Creates a string with the given value
|
AppianPrimitive |
createTime(Time value)
Creates a time with the given value
|
static AppianTypeFactory |
newInstance(com.appiancorp.suiteapi.type.TypeService ts) |
AppianElement |
toAppianElement(com.appiancorp.suiteapi.process.ProcessVariableInstance pvi)
Converts the given ProcessVariableInstance into an element
|
AppianElement |
toAppianElement(com.appiancorp.suiteapi.type.TypedValue tv)
Converts the given TypedValue into an element
|
<T> T |
toJavaObject(AppianObject object,
Class<T> clazz)
Creates a new instance of a concrete Java object from an AppianObject.
|
<T> T |
toJavaObject(com.appiancorp.suiteapi.type.TypedValue tv,
Class<T> clazz)
Creates a new instance of a concrete Java object from a TypedValue
|
com.appiancorp.suiteapi.type.TypedValue |
toTypedValue(AppianElement element)
Converts the given element into a TypedValue
|
void |
walkElementTree(AppianElement element,
AppianElementVisitor visitor)
Walks an element tree at the given starting element.
|
public AppianElement toAppianElement(com.appiancorp.suiteapi.type.TypedValue tv)
tv
- the TypedValue to be converted to an AppianElementpublic AppianElement toAppianElement(com.appiancorp.suiteapi.process.ProcessVariableInstance pvi)
pvi
- the ProcessVariableInstance to be converted to an AppianElementpublic com.appiancorp.suiteapi.type.TypedValue toTypedValue(AppianElement element)
element
- the element to be converted to a TypedValuepublic <T> T toJavaObject(com.appiancorp.suiteapi.type.TypedValue tv, Class<T> clazz) throws JAXBException
tv
- The TypedValue to be converted to an AppianElementclazz
- The JAXB annotated Java class representing the TypedValue structureJAXBException
ClassCastException
- if the TypedValue is not an AppianObject
public <T> T toJavaObject(AppianObject object, Class<T> clazz) throws JAXBException
XmlRootElement
object
- The complex Appian type to create a Java object forclazz
- The JAXB annotated Java class representing the TypedValue structureJAXBException
public void walkElementTree(AppianElement element, AppianElementVisitor visitor) throws Exception
AppianElementVisitResult.TERMINATE
. Where a visit
method terminates due an Exception the traversal is terminated and the error or exception is propagated to the caller of this method.element
- the starting element to traversevisitor
- the element visitor to invoke with each element foundException
- if an exception is thrown by a visitor methodpublic AppianElement createElement(long typeId)
typeId
- the Appian type id to create an element ofAppianList
, AppianObject
or AppianPrimitive
AppianList
,
AppianObject
,
AppianPrimitive
public AppianList createList(long typeId)
typeId
- the type to create a list ofpublic AppianPrimitive createBoolean(Boolean value)
value
- the initial valuepublic AppianPrimitive createDate(Date value)
value
- the initial valuepublic AppianPrimitive createDateTime(Timestamp value)
value
- the initial valuepublic AppianPrimitive createDouble(Double value)
value
- the initial valuepublic AppianPrimitive createLong(Long value)
value
- the initial valuepublic AppianPrimitive createString(String value)
value
- the initial valuepublic AppianPrimitive createTime(Time value)
value
- the initial valuepublic static final AppianTypeFactory newInstance(com.appiancorp.suiteapi.type.TypeService ts)
Copyright © 2018 Appian Corporation. All rights reserved.