Giving to @XmlJavaTypeAdapter a generic type value

Hi all
I have a critical problem with adapters used at jaxb unmarshall
some of my fields have type enumeration. I decided that is best to use same adapter class for all enums so i created a generic enumeration adapter. I'm not sure if is 100% ok but here it is:
EnumerationAdapter.java :
public class EnumerationAdapter<T extends Enum<T> > extends XmlAdapter<String, Enum<?>> {
    private Class<T> _enumClass;
     * (non-Javadoc)
     * @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object)
    @Override
    public String marshal(Enum<?> e) throws Exception {
        return e.toString();
     * (non-Javadoc)
     * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
    @Override
    public Enum<?> unmarshal(String v) throws Exception {
        // TODO Auto-generated method stub
        return T.valueOf(_enumClass, value);
}The adapter is called at unmarshall but i can't set type T as i want.
The problem is how i declare @XmlJavaTypeAdapter annotation that.
It should be something like this.
@XmlJavaTypeAdapter(EnumerationAdapter<MyEnum>.class)
protected MyEnum field;Of course syntactically is wrong, but i don't know how to declare it correctly. I.m not sure if at least this is possible.
Also i've noticed that i have to give explicit types to annotations ( not like xxx.getClass() ) :(
So I'm in deep d***, please do try to help me.
Thanks all.
Best regards
Marian

I was using it until i discovered a nasty issue
On short: I'm developing an suite of applications that receive an xml command(validated with a xsd schema), unmarshall it in a class. Then do a lot of stuff and then marshall back in xml structure then send it further.
The issue was that i have differentiate an empty xmle element from a missing one. So for tags that are not present is all ok, those xml elements will be ignored and in clas object them will have null value. All good for now.
But if i receive an empty xml element ( this means that i have to set null value for that field in a database...), i have to unmarshall this xml element into a "special" value(different from null) in order to know that i have to recreate empty tag for this element when i marshal object class back into xml command.
So i decided that that fastest solution is to use custom adapters and unmarshall empty tags into null strings for strings ( no [problem here), MININT value for numeric elements; and elements of type enum to use a convention enumfield NULL_VALUE (that i add for every enumeration).
I know that this solution is far from the best but for me i think is the fastest, and this is what matters for me now.
A better solution was to add for every element ( or at least for all non string elements) a field indicator that i set to true when xml element is present and false when is not).
These fields may be regular class members or even annotation for members.
This i can do easily cos all my schema and my classes are generated automatically ( open architecture projects or xjc), and for additionals fields or annotations i can use jaxb plugins, but i have to customize marshall/unmarshall process.
I'm not very familiar with this so it probably will take me at least day or two and i cannot afford to lose even an hour without an concrete result. :(
Hope i wasn't very ambiguous in presentation.
If u have any advice for me please do post it. Thanks again and have a nice day.
Edited by: grandanat on Apr 30, 2009 8:05 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Creation of a Table Type value set with 'ALL' as one of the  value

    Gurus,
    My requirement is to create [table type]value set which would show the [LOV]values in parameter of Conc Progr .
    So far we have three such values to chose from ,they are, 'Frozen', 'Pending' and 'Testing'. I achieved it.
    My question is ,
    if user wants to choose 'ALL' three values , how shall I accommodate it in this table type value set?
    Giving fourth option as ALL, which would eventually select 'ALL' three values 'Frozen', 'Pending' and 'Testing'.
    thanks in advance.
    -sDJ

    You can't have UNION in the value set.
    Try creating a view, which is having UNION with ALL.
    Check the following links.
    Table Value Set.
    ORA-00907 Missing Right Parenthesis in Value Set
    By
    Vamsi

  • Nested-Generic Type with the same parameter as enclosing type?

    Greetings. I want to write a nested generic type with the same type parameter as the enclosing type. For example, consider:
    public interface BinaryTree<Type> {
         Node<Type> getRoot();
         interface Node<Type> {
              Type getValue();
              void setValue(Type value);
              Node<Type> getLeft();
              void setLeft(Node<Type> node);
              Node<Type> getRight();
              void setRight(Node<Type> node);
    }In this example, I want Node to be specified to the same type as the binary tree's parameter specification. Does anyone know how to do that? I have tried several methods and am at a loss.
    TIA

    Is there any way to declare that? Essentially I want
    the nested type to parameterize the enclosing type.I understand that but I don't think it's possible because of how java generics works.
    This ,
    SomeClass< SomeNestedClass<Type> >is wrong because you're supposed to give a formal type parameter within <> not an already defined type (like SomeNestedClass).
    If you instead do
    public class SomeClass<Type > {
        public static class SomeNestedClass<Type> {
    }To think of the two Type as the same formal type parameter is semantically incorrect. Both the outer type and the inner type must be able to participate in variable declarations "on their own". Say you do
    SomeClass<Integer> sc;Just because you did the above in which context is now SomeNestedClass supposed to be bound as SomeNestedClass<Integer>? To me this shows that SomeClass and SomeNestedClass cannot share the same formal type parameter.

  • How can i restrict the Expenditure Type values at a specific OU ?

    Dear Guys,
    I would like to ask about the Expenditure Types,
    I have implemented two projects for different Operating Units ,
    when navigating to any Projects responsibilty,and navigating the Expenditure Type field
    the values exist are all the values implemented across the OU not the values entered at this OU
    How can i restrict the Expenditure Type values at a specific OU
    Regards
    Amr Hussien

    Hello
    When you set up a project there is an option called Transaction Control.
    This option allow you to list the allowed or restricted elements of costs for the project.
    You may enter the transaction control on a project template and that will be copied to any new project.
    The cost elements may be expenditure types, expenditures categories, suppliers, employees, etc.
    In your case, I suggest to set up specific project templates for each operating units. On each template enter the list of allowed expenditures types for that OU.
    Doing so, the system restricts users from entering any expenditure item, supplier invoice, purchase cost etc, against an expenditure type, which is not allowed.
    Dina

  • Reference to generic type Set E should be parmeterized

    I have the following code in a class:
    1:Event theEvent = (Event) session.load(Event.class, eventId);
                2:Set<Event> eventSet;
                3:eventSet = user.getFavouriteEvents();
                4:eventSet.add(theEvent);At line 3, I get the following warning message:
    Type safety: The expresson of raw type Set is converted to Set<Event>. References to generic type Set<E> should be parameterized.
    What does this mean? What do I need to do to get past this warning.
    Thanks
    Sharma

    Found the problem. I forgot to parameterize the Set in the getFavouriteEvents() method.
    Thanks
    Sharma

  • How to change the manual condition type value in change sales order BAPI

    Hi All,
    My scenario here is, i want to either add/change the manual condition type value during change of SO.
    When i'm trying to pass the  order_conditions_in and  order_conditions_inx tables in  'BAPI_SALESORDER_CHANGE'.
    Condition type is coming at item level but the value is setting to zero. Pls. help if anyone has any idea how to handle this.

    Siva,
       I guess you posted in Wrong Thread. You need to post in WAS section.
       check for any BAPI's available in CRM.
    Nagesh Ganisetti.

  • How to create an array with Generic type?

    Hi,
    I need to create a typed array T[] from an object array Object[]. This is due to legacy code integration with older collections.
    The method signature is simple:public static <T> T[] toTypedArray(Object[] objects)I tried using multiple implementations and go over them in the debugger. None of them create a typed collection as far as I can tell. The type is always Object[].
    A simple implementation is just to cast the array and return, however this is not so safe.
    What is interesting is that if I create ArrayList<String>, the debugger shows the type of the array in the list as String[].
    If I create ArrayList<T>, the class contains Object[] and not T[].
    I also triedT[] array = (T[]) Array.newInstance(T[].class.getComponentType(), objects.length);And a few other combinations. All work at runtime, create multiple compilation warnings, and none actually creates T[] array at runtime.
    Maybe I am missing something, but Array.newInstace(...) is supposed to create a typed array, and I cannot see any clean way to pass Class<T> into it.T[].class.getComponentType()Returns something based on object and not on T, and T.class is not possible.
    So is there anything really wrong here, or should I simply cast the array and live with the warnings?
    Any help appreciated!

    Ok. May be you could keep information about generic type in the your class:
    public class Util {
        public static <T> T[] toTypedArray(Class<T> cls, Object[] objects){
            int size = objects.length;
            T[] t = (T[]) java.lang.reflect.Array.newInstance(cls, size);
            System.arraycopy(objects, 0, t, 0, size);
            return t;
    public class Sample<T> {
        Class<T> cls;
        T[] array;
        public Sample(Class<T> cls) {
            this.cls = cls;
        public void setArray(Object[] objects){
            array = Util.toTypedArray(cls, objects);
        public T[] getArray(){
            return array;
        public static void main(String[] args) {
            Object[] objects = new Object[] { new LinkedList(), new ArrayList()};
            Sample<List> myClass = new  Sample<List>(List.class);
            myClass.setArray(objects);
            for(List elem: myClass.getArray()){
                System.out.println(elem.getClass().getName());
    }

  • Import from database an internal table with generic Type : Web Dynpro ABAP

    Hi everyone,
    i have a requirement in which i'm asked to transfer data flow between two frameworks, from WD Component to another. The problem is that i have to transfer internal tables with generic types. i used the import/ export from database approache but in that way i get an error message saying "Object references and data references not yet supported".
    Here is my code to extract a generic internal table from memory.
        DATA l_table_f4 TYPE TABLE OF REF TO data.
      FIELD-SYMBOLS: <l_table_f4> TYPE STANDARD TABLE.
      DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
      DATA: ls_indx TYPE indx.
      lo_componentcontroller =   wd_this->get_componentcontroller_ctr( ).
      lo_componentcontroller->fire_vh_search_action_evt( ).
      ASSIGN l_table_f4 TO <l_table_f4>.
    *-- Import table for Help F4
      IMPORT l_table_f4 TO <l_table_f4> FROM DATABASE indx(v1) TO ls_indx ID 'table_help_f4_ID'.
    The error message is desplayed when last instruction is executed " IMPORT l_table_f4...".
    I saw another post facing the same problem but never solved "Generic Type for import Database".
    Please can anyone help ?
    Thanks & Kind regards.

    hi KIan,
    go:
    general type
    TYPE : BEGIN OF ty_itab,
               field1 TYPE ztab-field1,
               field2 TYPE ztab-field2,
    *your own fields here:
               field TYPE i,
               field(30) TYPE c,
               END OF ty_itab.
    work area
    DATA : gw_itab TYPE ty_itab.
    internal table
    DATA : gt_itab TYPE TABLE OF ty_itab.
    hope this helps
    ec

  • MM Pricing Condition Type values in Condition Tab updation while CHANGE PO.

    Hi,
    The process of PO creation and PO change is through inbound IDOC posting.
    I created a PO with configured MM pricing procedure.
    While creating PO, the PO is created as required with different Condition Type value break-ups [PBXX, Discount, Surcharge etc] in the PO as required via Inbound IDOC processing.
    While CHANGING the same PO, the Condition Type break-ups [i.e. pricing related values] in the PO are NOT changing in the PO via Inbound IDOC processing.
    What needs to be done to update the Condition Type break-ups in the PO while changing PO through IDOC processing process?
    This problem is not occured while manual / on-line changing of PO valueS and saving the PO & exists through IDOC processing method ONLY.
    Thanks in Adv,
    RK

    Hi
    Try this function module
    FM RV_CHECK_CONDITION_VALUE
    Regards
    Hareesh Menon

  • Java5: Can't find a way to get rid of warnings about generic types

    Hi all,
    i have this method:
        public static void insert(List list, int index, Object obj) {
            list.add(obj);
            int j = list.size() - 1;
            for (; j > index; j--) {
                list.set(j - 1, list.get(j));
            list.set(index, obj);
        }I get 3 warnings. All about:
    Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized
    I can't find a way to rewrite this method (Java5), that i get no warnings compiling it and calling it with:
    List<AnyClass> list = new ArrayList<AnyClass>();
    list.add(new AnyClass());
    AnyClass ac = new AnyClass();
    insert(list, 0, ac);May be you know another way to insert an element to a List?
    Thanks

    Never tried it and do not have 5.0 installed to test
    it, but what if you define the ArrayList as follows?
    List<Object> list = new ArrayList<Object>();
    That should get rid of the warnings.

  • Exchange BPA Errors (Exchange server is a virtual machine but the additional tools are not installed and The 'Services' string type value located in 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ExchangeServer\v14\Setup\Services' registry key is missing)

    Hi,
    I am running BPA on My Exchange 2010 VM (Server 2008 R2 VM on Hyper-V) and get the following errors:
    The 'Services' string type value located in 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ExchangeServer\v14\Setup\Services' registry key is missing or inaccessible. The Microsoft Exchange Information Store service won't start. As a result, all services that depend
    on this service won't be able to start
    Exchange server [Exchange Server FQDN] is a virtual machine but the additional tools are not installed. This configuration is not supported. Install Virtual Machine Additions for this guest.
    Problem is that, for the first, that Key exists and the service is actually running fine. And for the second my VM tools are already installed.
    Hopefully someone out there has had the same issue and can assist.
    Pete

    Hi Pete,
    For the first error message, please try the following steps:
    Make sure the Information Store service is in Starting status,
    Automatic startup type and works well, as a test we can try to
    restart the Infroamtion Store service and verify the service works well.
    Start
    Registry Editor, find the registry key “Services” under “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ExchangeServer\v14\Setup”, its value is “C:\Program
    files\Microsoft\Exchange Server\v14”(default install location), please check your registry, make sure the key “Services” exist and value is the Exchange Server install location and the
    location is accessible;
    Start
    Registry Editor, and locate the following registry key:
    HKEY_LOCAL_MACHINE\Software\Microsoft\Exchange\Setup
    Use the
    Permission option under the Security tab to check the permission setting on this key. Make sure
    System is in the list with Full Control permissions if the service account is Local System. If you are not using Local System as the service account, check the existence of the corresponding account in the list and ensure that
    it has Full Control permissions. Please refer to this article:
    Title: Exchange Store Does Not Start: Errors 7024, 1026, 9542, and 5000
    Link:
    http://support.microsoft.com/kb/285116
    Start
    ADSI Edit, and then browse to the following location:
    Domain.com/Configuration/Services/Microsoft Exchange/Org/Administrative Groups/AdminGroup/Servers/Server Name
    Right-click the
    server name, and then click Properties.
    Click the
    Security tab, make sure this own server’s server object have
    full control permission on its own server.
    If not or the object is missing, please modify the permission or click
    Add, locate the computer account for the Exchange Server computer, add it to the Permissions list with full control.
    Click OK, and then close ADSI Edit.
    Use
    Active Directory Users and Computers to add the current affected
    Exchange Server computer account to the Exchange Servers(previous version should be “Exchange Domain Servers”) group in the
    Microsoft Exchange Security Groups( or Users) OU. Refer to this article:
    http://support.microsoft.com/kb/297295.
    Restart the Exchange Server computer, then rerun the ExBPA.
    For the second error message, Microsoft don’t recommend to install Exchange Server on virtual machine without additional tools, so the error message occurs. We can just ignore
    this message, it will not affect the Exchange servers.
    Regards, Eric Zou

  • Pricing : Condition type value need tog get from the lowest of 4 other cond

    Hi,
    I have one requirement in one pricing procedure.
    I need to calculate condition value of one condition type from the lowest value of other 4 condition tyeps. These condition types values are not defined as a subtotal.
    So if I decide to write a formula on condition values, is there
    any way to select these values and choose the lowest of them?
    Please also advice if there is any other way such as condition exclusion
    or so?
    Thanks and regards,
    Anand

    Anand,
    As you have mentioned you can use condition exclusion for such a requirement.
    here is a detailed description of how you can achieve this: use the menu path IMG> Sales & Distribution> Basic Functions> Pricing> Condition Exclusion> Condition exclusion for group of conditions.
    When you execute this IMG acitivity you get a window with three options
    1.Define Condition Exclusion Groups
    2.Assign condition types to the exclusion groups
    3.Maintain condition exclusion for pricing procedures
    We will use these three options one by one, we start with the first
    1. Define an exclusion group, lets say EX01 and give a description
    2 Assign the four condition types that you want to compare to this exclusion group under this option
       lets say EX01 ZK01
                   EX01 ZK02
                   EX01 ZK03
                   EX01 Zk04
    3. under this third step, select the pricing procedure that you are working on and from the left margin click on 'Exclusion'. click on 'New Entries' and make the following entries (example)
             Sno.   Cpr         ExGr1
              10      A            EX01                leave ExGr2 blank, Save your entries
    Check if your purpose has been met or not. Do give your feedback
    Regards,
    PATHIK

  • Condition type value not update in sales order

    Hello Guru's
    As per the  sales order in VA01 the condition type value i.e surcharge value is not updating in sales order.
    But I have maintain the condition record(Surcharge)also and in Condition technique I have checked every thing is correct .
    please find below I have attached the Screen short .
    Please give me solution Asap.

    Hi Sukdev,
    Have you checked the respective pricing procedure for From and To reference step maintained against the condition type ZSUR?
    Regards,
    T.R.S.Praveen

  • 'ResourceDictionary' root element is a generic type and requires a x:Class attribute to support the x:TypeArguments attribute sp

    Error : 'ResourceDictionary' root element is a generic type and requires a x:Class attribute to support the x:TypeArguments attribute specified on the root element tag.
    Hi,
    I get this error when i include some namespaces in my ResourceDictionary to specify a Style for a custom control.
    Can anyone help me?
    Thx
    Stardusty

    Hi,
    That's the whole point. I don't want to use x:TypeArguments on a ResourceDictionary but the compiler says it needs it.
    And i don't know why.
    This code give no error:
    <ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespaceystem;assembly=mscorlib">  
    </ResourceDictionary>
    And by adding 3 namespaces it gives that weard error:
    <ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:MyTime.View.Controls"
    xmlns:converters="clr-namespace:MyTime.View.Converters"
    xmlns:validationrules="clr-namespace:MyTime.View.ValidationRules"
    xmlns:sys="clr-namespaceystem;assembly=mscorlib">  
    </ResourceDictionary>

  • Generic type doesn't support raw dataypes (int, boolean, etc.)?

    It seems that Java 5 generics always autoboxes raw datatypes (int, double, boolean, ...) to the wrapper classes (Integer, Double, Boolean, ...), because when I use e.g. Integer.TYPE (instead of Integer.class), I got ClassCastExceptions. Is this non-support somewhere written down or is there a way to handle raw types without autoboxing them to their wrapper class?

    I'm having some difficulty understanding your question, but my first suggestion is to see section 4.4 Type Variables of the Java Language Specification, which states: "If no bound is given for a type variable, Object is assumed."
    Also, I think you mean "primivite" instead of "raw" types. Raw types are the "name of a generic type declaration used without any accompanying
    actual type parameters" (sectoin 4.8 Raw Types).
    Regards,
    Nick

Maybe you are looking for

  • How to correct the sequence of pricing condition in ME21N

    Hi, I checked the sequence of pricing condition for a contract in ME33K in Quality and development server, the sequence is correct in both ME33K  and ME21N also but I faced the problem the pricing condition showing in reverse order in ME21N as compar

  • Convert OTF along with Print preview in SAP Script

    Hello All, I was getting a print Preview for the sap script, now with the new requirement, I had to capture otf data too in OPEN_FORM. so I have added  "TDGETOTF = X", and that gives me otf data which I am converting it to PDF. now the problem is I a

  • Problem in adding Custom Provider for Work Management Service

    Hello, I'm facing an issue in adding custom provider for work management service. As you are aware, Work management service is a Provider model and we can integrate with other systems by adding custom providers. So with that confidence, i have starte

  • Interactive reporting problem in CRM 5.2

    Hello Everybody, We have installed SAP CRM 5.2 and with the help of Web UI able to do all transactions like account management,lead,Opportunity management and creating sales order etc... but when i click on Reports ( as BI is integrated to CRM in SAP

  • BOE XI Page Server ODBC DSN Login Prompt

    I created an ODBC data source to a csv file, then designed a Crystal Report using the ODBC data source.  I am working on the server where BOE XI is installed.  The server is logged onto the network, and has a drive mapped to the network folder that c