Smart Service plugin - how to cast Typevalue to a CDT

Hi All, I have developed a smart service plugin with an input argument (below). So I can pass any type of argument to the parameter.

@Input(required = Required.ALWAYS)
@Name("properties")
public void setProperties(TypedValue properties[])
{
this.properties=properties;
}

And also I have a CDT in same a plugin with getter and setter methods.

@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlType(name="NTRSProperty", namespace=NTRSProperty.NAMESPACE, propOrder = {
"name",
"type",
"value"
})

public class TestProperty

I also declared TypeService as an argument in plugin constructor for retrieving CDT instance properties. My intention is to iterate thru TypedValue properties[] and cast properties[index] to TestProperty (CDT in same plugin application)

Please let me know how to cast objects? is it possible to cast objects? All I want is the value (even as text) of TypedValue  object so I have a way to parse the value and get attributes of TestProperty.

Thanks

Jayanth

Parents
  • I found one way of fetching the value of TypeValue, below is snippet

    //TypedValue[] properties

    for(int i=0;i<properties.length;i++)
    {

    System.out.println("properties[i].toString() " + properties[i].toString());

    outputs

    properties[i].toString() TypedValue[it=6462,v={{{DocumentTitle,string,PluginTest}}}]

    properties[i].toString() TypedValue[it=6462,v={{{DocumentTitle,string,hello!'()%@`~#%^&*{}:;}}}]

    }

    I think i can apply regex and get CDT attribute values.

Reply
  • I found one way of fetching the value of TypeValue, below is snippet

    //TypedValue[] properties

    for(int i=0;i<properties.length;i++)
    {

    System.out.println("properties[i].toString() " + properties[i].toString());

    outputs

    properties[i].toString() TypedValue[it=6462,v={{{DocumentTitle,string,PluginTest}}}]

    properties[i].toString() TypedValue[it=6462,v={{{DocumentTitle,string,hello!'()%@`~#%^&*{}:;}}}]

    }

    I think i can apply regex and get CDT attribute values.

Children
No Data

 Discussion posts and replies are publicly visible