Problem converting java.util.HashMap in an ActionScript object

I have this weird problem and I can't figure it out, let me explain:

I have a java object A that has a variable myMap HashMap, this card will hold objects of class b. inside B is an instance of class C. In ActionScript, I have A corresponding class that has a myMap variable, but since no HashMap in ActionScript type is Object and I also have corresponding, B and C classes.

[RemoteClass(alias="com.test.A")]
public class A {}
public var myMap:Object; It's the hash in Java table
}

[RemoteClass(alias="com.test.B")]
public class B {}
public var: identification number;
public var name: String;
public var myC: C
}

[RemoteClass(alias="com.test.C")]
{} public class C
public var myId:Number;
public var myName:String;
}

I need to put objects C of each object B of the card inside a DataGrid control, so I get the class A with a RemoteObject object and then I iterate on myMap property using a foreach loop, like this:

for each {(var i: * dans objectA.myMap)}
someArrayCollection.add (i.myC);
}

The first issue was published here, java HashMap contains 3 elements, in the loop of the ActionScript I get 4 items, the fourth being a reference to an object. To avoid this, I use the operator "is" like this:

for each {(var i: * dans objectA.myMap)}
(if I is B) {}
someArrayCollection.add (i.myC);
}
}

Now, here's the real problem, when I do that objects C contained in the myMap property B objects are reset to their original values (myId is NaN and MyName is an empty string according to class C). I changed the if this condition and worked:

for each {(var i: * dans objectA.myMap)}
If (!) () I is A)) {}
someArrayCollection.add (i.myC);
}
}
When I did the control DataGrid displays the values of the perfectly good C (myId and MyName) objects. I did a little more testing and I 'found' the question, if I use an instance of the class B anywhere in my application, the values of the C object are reset, for example:

for each {(var i: * dans objectA.myMap)}
(if I is B) {}
someArrayCollection.add (i.myC);
}
}
var test: B = new B();

This resets the object C (myId and MyName) of each object B contained in the plan of a being that has no absolute meaning.

If the thing is when I use the B class, which is the class of the objects inside myMap, C objects are set to zero. Does anyone know how to fix this?

I'm using Flex 2.01 hotfix 3, I wonder if it's some kind of bug that has been fixed in a later version.

Any help would be appreciated.

OK I fixed it, as I have said that my app was a more complicated scenario here is what happened:

The C object is the superclass of the D and E, and the Java service puts the D or E, objects inside the property of object B myC, myC type C and C is the super class D and E, then it works.

The problem is that in Flex object C inside B is actually a D or E object, I just had to use an instance of D and E somewhere in the code, that is why Flash Player included these classes.

Anyway, I know it's all complicated, but the good news is that it works now

Tags: Flex

Similar Questions

  • Basic question on java.util.HashMap

    Hello

    Say I want to store the number of copies of books like the value of a HashMap and use the key of the book object. Suppose that my book objects are very large.

    My question is this: will my HashMap object store the actual book or simply use the result of the hash function (called on my book of things) to 'put' a new book as well as the number of copies in the hash table?

    Here's how "to" the book in my card:
    myMap.put(firstBook, 8);
    myMap.put(secondBook, 2);
    etc...
    Thanks in advance for your help,

    J.

    Baltea wrote:
    Hello

    Say I want to store the number of copies of books like the value of a HashMap and use the key of the book object. Suppose that my book objects are very large.

    My question is this: will my HashMap object store the actual book or simply use the result of the hash function (called on my book of things) to 'put' a new book as well as the number of copies in the hash table?

    No objects are copied (except if you explicitly copy) and no objects are stored in the map. (Indeed, no object is is never stored "inside" other objects in Java.) The hash table stores a reference to the key object and a reference to the value object. But also long your exsists in key-value pair in the leaf of the object key and the value object will be resident in memory and GC in United Nations.

    Edited by: jverd December 20, 2010 11:31

  • problem of java.util.Date

    Hi gurus,

    My requirement, that is to make a date validation, a process runs only between January 1 and 5, how can I retrieve the current year and place it in a two variables, so I can compare to the current day... I try to do this without success, when I ran the app shows me error, I am doing this with OFA, here is my code:

    OANLSServices service = pageContext.getOANLSServices ();
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/YYYY");
    Day dToday = new Date();
    String sToday = sdf.format (dToday);
    dToday = services.stringToDate (sToday);
    Date d1 = new Date();
    Date d2 = new Date();
    String s1 = sdf.format (d1);
    String s2 = (d2) sdf.format;
    D1 = services.stringToDate (s1);
    D2 = services.stringToDate (s2);
    D1. SetDate (1);
    D1.setMonth (1);
    D1.setYear (dToday.GetYear ());
    D2. SetDate (5);
    D2.setMonth (1);
    D2.setYear (dToday.GetYear ());
    If ((dToday.equals (d1) | dToday.after (d1)) & & (dToday.equals (d2): dToday.before (d2))) {}
    some instructions
    } else {}
    instructions of another
    }

    This seems to do the hard work of a simple problem. Why not just create a departure Date of 1 Jan 00:00 object, a last Date 5th Jan 23:59 object, then use Date methods to compare the Date of today with these two object?

  • Cannot convert abcd of the type class java.lang.String interface java.util.List

    Hello

    I get an error of "cannot convert the class type abcd java.lang.String interface java.util.List" where "abcd" is a string in a listbox.

    and my code is something like this

    < af:selectOneListbox id = "lstcatg" label = 'List of categories' partialTriggers = 'proud '.

    value = "#{viewScope.RegWoComp.lstboxcatg}" >

    < f: selectItems id = value="#{viewScope.RegWoComp.customList}"/ "lstselect1" >

    < / af:selectOneListbox >


    bean

    private list < String > lstboxcatg;

    {} public void setLstboxcatg (List < String > lstboxcatg)

    This.lstboxcatg = lstboxcatg;

    }

    public List < String > getLstboxcatg() {}

    Return lstboxcatg;

    }

    public BindingContainer {} getBindings()

    Return BindingContext.getCurrent () .getCurrentBindingsEntry ();

    }

    Private Sub button (ActionEvent actionEvent)
    {
    JUCtrlListBinding listBindings = (JUCtrlListBinding) getBindings () .get (lstboxcatg);
    Object [] str = listBindings.getSelectedValues ();

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

    {

    System.out.println (STR [i]);

    }
    }

    I tried to use this fact.

    object str = listBindings.getSelectedValue ();

    System.out.println (STR);

    and here, if I change the data type of lstBoxcatg

    private String lstboxcatg;

    {} public void setLstboxcatg (String lstboxcatg)

    This.lstboxcatg = lstboxcatg;

    }

    public String getLstboxcatg() {}

    Return lstboxcatg;

    }

    can I get a nullpointerexception on line object str = listBindings.getSelectedValue ();

    No you can use this code you don't use link layer

    remove this code. You will get the selected value in this string variable

    Just write this about you button action and verification.

    System.out.println (selectedVal);

    Ashish

  • Conversion problem of oracle.jbo.domain.Date in java.util.Calendar and oracle.jbo.domain.Timestamp to oracle.jbo.domain.Date

    Hello world

    Work with dates has been harder than I thought! Please take a look at the code; everything compiles, but it fails because I'm not cast properly. Any help would be appreciated.

    Imports are:

    import java.sql.SQLException;

    to import java.text.ParseException;

    import impossible;

    import java.util.Calendar;

    Import oracle.jbo.domain.Date;

    Import oracle.jbo.domain.Timestamp;

    Here is the method:

    public static Date (String sDate, int day, nextDay

    SimpleDateFormat String) {}

    Date result = null;

    java.util.Date date;

    If (sDate! = null) {}

    try {}

    System.out.println ("Try...");

    Calendar calendar = Calendar.GetInstance ();

    SimpleDateFormat dateFormat =

    new SimpleDateFormat (simpleDateFormat);

    calendar.setTime (dateFormat.parse (sDate));

    Calendar.Set (Calendar.DAY_OF_WEEK, date); day = Calendar.SUNDAY

    Calendar.Set (Calendar.HOUR_OF_DAY, 0);

    Calendar.Set (Calendar.MINUTE, 0);

    Calendar.Set (Calendar.SECOND, 0);

    Calendar.Add (Calendar.DATE, 7);

    dateFormat.format (calendar.getTime ());

    try {}

    System.out.println ("try (inside)... ») ;

    "System.out.println (" new Timestamp (calendar.getTime () .getTime ()) "):" +.

    new Timestamp (calendar.getTime () .getTime ()));

    result = new Date (Timestamp (calendar.getTime () .getTime ())) new; Code does not work here.

    return the result;

    } catch (SQLException e) {}

    System.out.println ("catch (SQLException e)... ») ;

    e.printStackTrace ();

    }

    Returns a null value.

    } catch (ParseException exception) e {}

    System.out.println ("catch exception e ParseException... ») ;

    e.printStackTrace ();

    }

    Returns a null value.

    }

    Returns a null value.

    }

    Here is the result:

    try...

    Try (inside)...

    new Timestamp (calendar.getTime () .getTime ())): 2013-12-29 00:00:00.0

    catch (SQLException e)...

    java.sql.SQLException: failed initialization

    to oracle.sql.DATE. < init > (DATE.java:237)

    to oracle.jbo.domain.Date. < init > (Date.java:378)

    James

    try to convert timestamp to jbo.date as

    java.sql.Timestamp datetime =newjava.sql.Timestamp(System.currentTimeMillis());

    oracle.jbo.domain.Date daTime =new  oracle.jbo.domain.Date(datetime);

  • Convert a Java.util.date in Timestamp

    I have a date of type java.util.Date
    Date today = new Date();
    which is in the format Tue Jan 10 00:00:00 IST 2012

    I need to convert the format to insert it into the Oracle database below

    2012-01-17 00:00:00.0


    Java version: 1.5

    Can someone help me in this.

    Hello

    Why not try with SimpleDateFormat ?

    D.

  • the resolution may not be cast in java.util.ArrayList

    I hava an accordion panel with this function in disclosureListener:

    {} public void terrababdelhak (DisclosureEvent disclosureEvent)

    System.out.println ("SHOW all THE NEWSPAPERS");

    int stateIndex [---]

    DCIteratorBinding dcLogs = (DCIteratorBinding) getBindings () .get ("LogTypesVO1Iterator");

    ViewObject voLogs = dcLogs.getViewObject ();

    List of JUCtrlListBinding = (JUCtrlListBinding) getBindings () .get ("LogTypesVO1");

    System.out.println ("LIST LOGS" + list);

    DCIteratorBinding iter = list.getDCIteratorBinding ();

    System.out.println ("ITER LOGS" + iter);

    RowSetIterator rsi = voLogs.createRowSetIterator (null);

    System.out.println ("RSI" + rsi);

    int i = 0;

    rowCount int = (int) voLogs.getEstimatedRowCount ();

    stateIndex = new int [rowCount];

    While (rsi.hasNext ()) {}

    System.out.println ("SEGUINTE!");

    Line nextRow = rsi.next ();

    iter.setCurrentRowWithKey (nextRow.getKey () .toStringFormat (true));

    INDX int = iter.getCurrentRowIndexInRange ();

    stateIndex [i] = indx;

    System.out.println ("Index loop-" + indx);

    i ++ ;

    }

    rsi.closeRowSetIterator ();

    System.out.println ("INDEX" + stateIndex);

    list.setSelectedIndices (stateIndex);

    System.out.println ("LISTA" + list);

    }

    Then I valuechangelister to selectmanycheckbox this function:

    {} public void filterLogs (ValueChangeEvent valueChangeEvent)

    Dc2 DCIteratorBinding = (DCIteratorBinding) evaluteEL ("#{bindings.") EntityLogsVO1Iterator}");

    ViewObject vo2 = dc2.getViewObject ();

    String WhereClause = "LOG_TYPE in (";"."

    System.out.println ("VALUE" + valueChangeEvent.getNewValue ());

    If (valueChangeEvent.getNewValue ()! = null) {}

    java.util.ArrayList selectedValues = (java.util.ArrayList) valueChangeEvent.getNewValue ();

    for (int i = 0; i < selectedValues.size (); i ++) {}

    If (!.) WhereClause.equals ("LOG_TYPE in (""))

    WhereClause += ', ';

    WhereClause += "'" + selectedValues.get (i) + "'";

    }

    WhereClause += ') ";

    VO2.setWhereClause (WhereClause);

    VO2. ExecuteQuery();

    } else {}

    WhereClause = "1 = 2";

    VO2.setWhereClause (WhereClause);

    VO2. ExecuteQuery();

    }

    }

    But when I uncheck a selectmanychoice point, cause this error:

    valueChangeListener = "#{backingBeanScope.backing_OrderDetail.filterLogs}": java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast in java.util.ArrayList.] "

    My selectmanycheckbox have this property:

    < af:selectManyCheckbox value = "#{bindings." LogTypesVO1.inputValue}.

    label = "#{bindings." LogTypesVO1.label}"id ="smc1.

    Simple Binding = "#{backingBeanScope.backing_OrderDetail.SMC1}" = 'true' "

    layout = "horizontal" autoSubmit = 'true '.

    valueChangeListener = "#{backingBeanScope.backing_OrderDetail.filterLogs}" >

    < f: selectItems value = "#{bindings." LogTypesVO1.items}"id ="si2 ".

    Binding="#{backingBeanScope.backing_OrderDetail.si2}"/ >

    < / af:selectManyCheckbox >

    my version of jdev is 11.2.4.0

    User

    You can not convert the ArrayList to direct object value

    java.util.ArrayList selectedValues = (java.util.ArrayList) valueChangeEvent.getNewValue ();

    write like this-

    ArrayList selectedValues = new ArrayList();

            Object [] str = (Object []) valueChangeEvent.getNewValue ();
            for (int i = 0; i)< str.length;="" i++)="" {="">
               

    System.out.println (STR [i]);

    selectedValues.add (str [i]); Add the values from an ArrayList

            }

    Ashish

  • java.lang.ClassCastException: java.util.ArrayList cannot be cast to oracle.adf.view.faces.bi.model.GeoMapDataModel

    Hello world

    LM l and map creation using table list as the data collection for the leaf theme of points to specify a given location. The problem l get here is that, after setting up the collection of data on the theme tab, the choice address and longtude & latitudes remain disabled. LM using JDeveloper 12 c last version & weblogic 12 c. When l run my lm project this error: java.lang.ClassCastException: java.util.ArrayList cannot be cast to oracle.adf.view.faces.bi.model.GeoMapDataModel. Here is the source code of my page and the Bean managed that define the ArrayList

    MapBean.pngPageSourceCode.png

    kdario Thanks for your comment, no. l didn't download the demo of component, but l did it right now. l use developer J 12 c to see how GeoMapDataModel is created .it will come back to you if any problem arises.

  • move on java.util.Map parameter to Servlet

    Hello

    I use jdeveloper 11.1.1.3.0

    I have set a java.util.Map as pageFlowScope parameter setting and fill in a bean:

    java.util.Map paramMap = new HashMap();
    paramMap.put("key1","value1");
    .
    .
    .
    Map<String, Object> pageflowScope =
    AdfFacesContext.getCurrentInstance().getPageFlowScope();
    pageflowScope.put("formParam", new HashMap());
    pageflowScope.put("formParam", paramMap);
    
    
    
    
    

    so, I want to send this parameter to servlet by a goLink as follows:

    <af:goLink text="goLink 1" id="gl1"
             destination="/render_image? param=#{pageFlowScope.formParam}"
       targetFrame="_blank"/>
    
    
    
    
    

    but in the servlet when I wanted to get this parameter the exception below occurs

    Map paramMap = (Map)request.getParameter("param");
    
    

    Error 500 - Internal server error

    java.lang.ClassCastException: java.lang.String cannot be cast java.util.Map

    How can I pass a parameter java.util.Map to servlet?

    Habib

    And that returns a String is a

    #{pageFlowScope.formParam}

    I guess?

    As a final attempt by me:

    1. before redirecting to servlet (by af:goLink), put your hashMap not the pageFlowScope, but the sessionScope attribute, say "formParam.

    2. in the redirect (when specifying the destination for the goLink), don't specify any parameter (jump? param =... part)

    3. in the servlet, try again with the code I gave you already:

    public void doGet (HttpServletRequest request,

    HttpServletResponse response) throws ServletException,.

    IOException {}

    HashMap param (HashMap) = request.getSession () .getAttribute ("formParam");

    }

    If this does not work, then I don't have the answer

  • Access denied ("java.util.PropertyPermission" "user.timezone', 'writing') [WINDOWS 7 64 bit]

    Hello

    that we got on several computers, the error message


    access denied (java.util.PropertyPermission""user.timezone', 'write')

    When we try to open an internal Web site. Until today, that everything worked well.

    An update of Java for windows 7 64, Version 7 45 update does not resolve the problem.

    I tried to set the Java security permissions in the control panel to the Middle, but it also did not work after this change.

    We also got this problem on another computer when you try to open an external site that also use the Java.

    Someone has any idea how to solve this problem?

    Hi guys.

    I solved the problem by adding a rule to the following file

    $JAVA_HOME\lib\security\java.policy

    grant {}

    ...

    permission java.util.PropertyPermission "user.timezone", "write";

    };

    After that I killed the java process and rebooted. The problem disappeared

  • Faulty decompression with java.util.zip

    Hello
    I want to use the java.util.zip classes to compress the contents of the files (BMP images) and later unpack for display. Strange thing is that the same method usihg some files decompress correctly, the other does not.
    I wrote the test code for compression/decompression of the contents of a file (input parameters are 'c leader ', compressed file is given the extension ".comp" which was released on decompression). Here are two images of test. Suite (compress the file & decompression the result):
    TestCompDecomp c A.bmp
    TestCompDecomp d A.bmp.comp... is OK
    but the same process with B.bmp leads to a corrupt image.
    package testcompdecomp;
    
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.zip.DataFormatException;
    import java.util.zip.Deflater;
    import java.util.zip.Inflater;
    
    public class TestCompDecomp {
    
         static class Compressor {
              // compresses byte array, returns compressed bytes in array
              public byte[] compress(byte[] bytesToCompress){          
                   Deflater compressor = new Deflater(java.util.zip.Deflater.BEST_COMPRESSION);
                   compressor.setInput(bytesToCompress);
                   compressor.finish();
                   byte[] bytesCompressed = new byte[2000000];
    
                   int numberOfBytesAfterCompression = compressor.deflate(bytesCompressed);
                   compressor.end();
                   byte[] returnValue = new byte[numberOfBytesAfterCompression];
                   System.arraycopy(     bytesCompressed, 0,     returnValue,     0, numberOfBytesAfterCompression);
                   return returnValue;
              }
    
              // decompresses byte array, returns decompressed bytes in array
              public byte[] decompress(byte[] bytesToDecompress) throws DataFormatException {
                   Inflater decompressor = new Inflater();
                   int numberOfBytesToDecompress = bytesToDecompress.length;
                   decompressor.setInput( bytesToDecompress, 0, numberOfBytesToDecompress);
                   int compressionFactorMaxLikely = 3;
                   int bufferSizeInBytes = numberOfBytesToDecompress * compressionFactorMaxLikely;
                   byte[] bytesDecompressed = new byte[bufferSizeInBytes];
    
                   int numberOfBytesAfterDecompression = decompressor.inflate(bytesDecompressed);          
                   decompressor.end();
                   byte[] returnValue = new byte[numberOfBytesAfterDecompression];
                   System.arraycopy( bytesDecompressed, 0, returnValue, 0, numberOfBytesAfterDecompression);     
                   return returnValue;
              }
         }
         
         public static void main(String[] args) throws IOException, DataFormatException {
              if (args.length < 2) {
                   System.out.format("usage: TestCompDecomp <command> <file>%n%n");
                   System.out.format("<commands>%n  c   compress file%n  d   decompress file%n");
                   System.exit(-1);
              }
              byte[] input = null;
              byte[] output = null;
    
              //     read file content into array
              File inputFile = new File(args[1]);
              try (InputStream stream = new FileInputStream(inputFile)) {
                   long length = inputFile.length();
                   input = new byte[(int)length];
                   int offset = 0, numRead = 0;
                   while (offset < input.length && numRead >= 0) {
                        numRead = stream.read(input, offset, input.length-offset);
                        offset += numRead;
                   }
              } catch (IOException e) {
                   System.err.println(args[1]+": read error");
                   System.exit(-1);
              }
              // process the file content
              Compressor compressor = new Compressor();
              switch (args[0]) {
                   case "c":     // compression
                        output = compressor.compress(input);
                        break;
                   case "d":     // decompression
                        output = compressor.decompress(input);
                        break;
                   default: ;
              }
              // write the processed bytes to tne output file
              FileOutputStream outFile = null;
              String outFileName = args[1];
              switch (args[0]) {
                   case "c":
                        outFileName += ".comp";
                        break;
                   case "d":
                        outFileName = outFileName.replace(".comp", "");
                        break;
              }
              try {
                   outFile = new FileOutputStream(outFileName);
                   outFile.write(output);
              } finally {
                   if (outFile != null)
                        outFile.close();
              }
         }
    }
    Any idea please?

    Quido

    Welcome to the forum!
    >
    I want to use the java.util.zip classes to compress the contents of the files (BMP images) and later unpack for display. Strange thing is that the same method usihg some files decompress correctly, the other does not.
    >
    That's pretty much what you should expect when you write code that has absolutely NO verification errors or parameter control at all.

    GIGO - Garbage In, Garbage Out.

    Your compression method uses an array of bytes for a parameter. This byte array can be any legal size.

    Then you HARD-CODE the size of the byte array target/tablet to 2 million bytes. You want to keep only the fingers crossed that the compressed size will fall into this buffer. And your method does not check for errors.

    What makes you think that an array of bytes in the entry that is 1 GB in size will compress in 2 million bytes?

    Then you make similar assumptions for the method to decompress; you ASSUME that the decompressed data size will be no more than three times the compressed size.

    int compressionFactorMaxLikely = 3;
    int bufferSizeInBytes = numberOfBytesToDecompress * compressionFactorMaxLikely;
    byte[] bytesDecompressed = new byte[bufferSizeInBytes];
    

    And you already know what's going to happen if your assumtions are wrong.

    If you want to learn how to write good code you can not make any assumptions as you do. If you make assumptions, you need to add code to validate that your assumptions are correct, check the length of the tables being passed and add the error handling so that you know when things are bad.

    The foregoing would be bad enough, but the biggest mistake you do is reinvent the wheel. You write custom code to implement features that Java already provides for you.

    The best solution to your problem is to simply create a zip file standard of your entry. ALWAYS, ALWAYS, ALWAYS start with the simplest solution that meets your needs.

    A solution of zip files:

    1. the uses out of the box functionality Java – you have to write code that interacts with the API classes
    2. you can read/write the files of any arbitrary size without having to allocate buffers of unknown size.
    3. has a very minimal overhead in the zip file for the central directory structure of input data that are necessary for a single file and zip.
    4 makes it easy to inspect the contents of the zip file, because the file can be opened with ANY zip utility.
    5. makes it easy test read and write functionality separately. Just use Winzip or another utility to create a zip of an example of BMP file and then test your code to see if you can decompress.
    6. you can only work with the flow of input/output instead of arrays of bytes.

    I suggest abandon you your current approach and implement a read/write zip utility that interfaces with your BMP files you need. Only if that is not your needs in the long run you must use a custom approach.

    There are many simple examples on the web that show how to create, read and write zip using Java files. And here are two:
    http://www.java2s.com/Tutorial/Java/0180__File/Createazipfile.htm
    http://www.java2s.com/Tutorial/Java/0180__File/Readzipfile.htm

  • How killi thread and stop java.util.Timer?

    Hello

    I have table list, this list contains my objects (areas of Thread) and these threads use the Timer (java.util.Timer).

    In some time, I need to find the object in the list of tables, destroy this specific thread and immediately to stop the timer.

    I don't know what is the best way how a) destroy the thread and b) stop the timer.

    Could you tell me what technique to use?

    Thank you.

    I don't think you're catching what everyone tells you:

    Unless I missed something in your code, you do the following:

    1 create a thread that starts a timer (the thread itself dies immediately after the launch of the timer)
    2 put the dead (or soon to die) wire reference in a list of tables.

    To solve your problem, as has already been said: stop timers, they exist independently of your son now dead. Remove the reference ArrayList where you keep a list of the dead son. They will be eligible for garbage collection when you have no refrence to them any longer. Java garbare collector will not immediately work to show you got something, it is that way by their design, but ultimately it will collect your dead and not referenced objects and drop them.

  • java.util.concurrent.Executor.execute)

    Hi all

    The API for java.util.concurrent.Executor.execute () says:

    Executes the given command at some point in the future. The command can execute in a new thread, a thread from the pool or in the calling thread, at the discretion of the implementation of the executor.

    If the calling thread is the EDT and I need to process something on a thread split to release the EDT and it is processed (by the execute() method) on the calling thread, which is the EDT, there would be a problem. Is there a way to tell execute() does not treat on the calling Thread?

    Thank you

    No standard implementations run on the current thread. It is all explained in the javadocs, with "known application classes.

  • Uncompilable source code - wrong type java.util.Collections.sort sym

    Hello

    I'm doing an exercise. I need to set up my own behaviour SortedSet, based on an implementation of LinkedList. Basically I check if an item is not already present in the list and then I want to sort the list using Collections.sort (). This is my piece of code:
    public class MySortedSet<E> {
        
        LinkedList<E> list = new LinkedList<E>();
        
        public boolean add(E e) {
            if (!list.contains(e)) {
                list.add(e);
                Collections.sort(list); //this line throws exception
                return true;
            }
            return false;
        }
        
        public static void main(String[] args) {        
            MySortedSet<String> mss = new MySortedSet<String>();
            mss.add("First");
        }
    }
    Only, I get the following exception:
    Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: java.util.Collections.sort
         at chapter17.MySortedSet.add(MySortedSet.java:23)
         at chapter17.MySortedSet.main(MySortedSet.java:48)
    Java Result: 1
    ... that I do not actually understand. NetBeans, tells me: no suitable method found to sort (java.util.LinkedList < E >), the method of java.util.Collections. < T > sorting (java.util.List < T >) is not applicable, the infrerred type is not consistent with the declared boundaries, deducted: E, limits: java.lang.Comparable <? Super E >.

    Of this kind, I understand that my list object is not correctly stated on this point is the generic type. LinkedList generic type E, what is false. Can someone explain to me how do I correctly report LinkedList, or otherwise I do wrong. I'm not sure that understand this generic problem here.

    Thank you
    PR.

    Collections.sort can only sort comparable objects (or use a separate comparison). You would need to have a Comparable upper limit for E.

  • Conversion of java.util.date in TimestampLTZ

    HIE

    How can I convert a java.util.date type oracle.jbo.domain.TimestampLTZ?

    Vik

    Since java.sql.Timestamp extended (i.e., "is a") java.util.Date, simply use the constructor Timestamp (java.sql.Timestamp):

    // y is a java.util.Date
    
    oracle.jbo.domain.TimestampLTZ x = new TimestampLTZ(y);
    

    http://download.Oracle.com/docs/CD/B25221_05/Web.1013/b16006/Oracle/JBO/domain/timestamp.html#Timestamp_java_util_Date _

Maybe you are looking for