Problems with sort, search and write objects o an ArrayList

Hi
Lets say that i have two subclasses (the program is not finished so in the end it can be up to 34 classes) of an abstract superclass. I also got one class which basicly is a register in which i've created an ArrayList of the type <abstractClass>. This means that i store the two subclasses in the arrayList. no problems so far i think (at least eclipse doesn't mind).
1. now, i want to be able to sort the arrayList aswell as search thorugh it. I've tried Collections.sort(arrayList) but it doesn't work. So i have no idea how to solve that.
2.The search-method i made doesn't work as good as i hoped for either. I ask the user to first decide what to search for (choose subclass) and then input the same properties as the subclass we search for. I create a new object of the subclass with these inputs and try arrayList.contains(subClassObject)
it runs but it returns +"false"+ even if i create an object with the exact same properties.
3. If i want to write this arrayList to a txtFile so i can import it another time. Which is the best method? first i just thought i'd convert the arrayList to string and then print every single object to a textfile as strings. that worked but i have no good idea how to import that into the same arrayList later. Then i found ObjectOutputStream and import using inputStream.nextObject(). But that doesn't work :(
Any ideas?
Thank you!
Anton

lavalampan wrote:
Hi
Lets say that i have two subclasses (the program is not finished so in the end it can be up to 34 classes) of an abstract superclass. I also got one class which basicly is a register in which i've created an ArrayList of the type <abstractClass>. This means that i store the two subclasses in the arrayList. no problems so far i think (at least eclipse doesn't mind).
1. now, i want to be able to sort the arrayList aswell as search thorugh it. I've tried Collections.sort(arrayList) but it doesn't work. So i have no idea how to solve that. Create a custom comparator.
>
2.The search-method i made doesn't work as good as i hoped for either. I ask the user to first decide what to search for (choose subclass) and then input the same properties as the subclass we search for. I create a new object of the subclass with these inputs and try arrayList.contains(subClassObject)
it runs but it returns +"false"+ even if i create an object with the exact same properties.Implement hashCode and equals.
>
3. If i want to write this arrayList to a txtFile so i can import it another time. Which is the best method? first i just thought i'd convert the arrayList to string and then print every single object to a textfile as strings. that worked but i have no good idea how to import that into the same arrayList later. Then i found ObjectOutputStream and import using inputStream.nextObject(). But that doesn't work :(Depends on what your requirement is, but yes, Serialization might work for you. Your classes should in that case implement Serializable.
Kaj

Similar Messages

  • Problem with removing Search and Advanced Search functionalities in Portal

    Hi,
          As per our client requirement, we have removed search and advanced search functionalities in Masthead and those are working fine. But when ever we restarted the portal server, these search options are reappearing in portal.
              I am not getting why it is happening and every time we restarted the server, we are removing these search functionalities from masthead.
              If anyone knows why it is happening, kindly share with us
    Thanks & Regards
    Pavan

    Hi Santosh,
                         Problem is not solved. Where can i find the Standard tool area iview used in Default frame work page ?
    At present, we disabeled the search and it's working fine. But when we restart the portal, search is again reappearing and we need to disable that once again.
               Is there any sollution for this problem?? Kindly let me know..
    Thanks & Regards
    Pavan
    Edited by: pavanakrishna reddy on Mar 24, 2010 9:44 AM

  • Problem with air read and write smb shared directory of file

    hi, everyone.
    I'm want to access smb directory of file,And to read and
    write operation, I would like to ask how I should do?
    Thanks!

    You can't access any OS facility nor execute arbitrary command.
    So the best solution is to mount samba directory BEFORE run your AIR application; you eventually can create a script that mount samba (and asks password) and then run you AIR application.
    see
    http://www.mikechambers.com/blog/2008/01/17/commandproxy-net-air-integration-proof-of-conc ept/
    for a more complex solution.

  • Have problems with Only Search and McKeeper

    hello,
    I made a big mistake: I 've downloaded the "MacKeeper".
    When I'm on Safari, I can't start through google, because there is always a mysterious "Only Search" that starts my researches even if I've given "google" as first page in Safari. Despite this, The "MacKeeper" alway opens itself on new pages even if I canceled it.
    Could somebody help me?
    Thenk'you very much
    Alex

    There is no need to download anything to solve this problem.
    You may have installed the "Downlite" or "VSearch" ad-injection malware. Follow the instructions on this Apple Support page to remove it.
    Back up all data before making any changes.
    Malware is always changing to get around the defenses against it. In addition to, or instead of, the files listed in the support article, you may need to remove the following items:
    /Library/Application Support/dot
    /Library/LaunchAgents/com.dot.agent.plist
    /Library/LaunchDaemons/com.dot.daemon.plist
    /Library/LaunchDaemons/com.dot.helper.plist
    /System/Library/Frameworks/v.framework
    One of the steps in the article is to remove malicious Safari extensions. Do the equivalent in the Chrome and Firefox browsers, if you use either of those. If Safari crashes on launch, skip that step and come back to it after you've done everything else.
    If you don't find any of the files or extensions listed, or if removing them doesn't stop the ad injection, then you may have one of the other kinds of adware covered by the support article. Follow the rest of the instructions in the article.
    The problem may have started when you downloaded and ran an application called "MPlayerX." That's the name of a legitimate free movie player, but the name is also used fraudulently to distribute VSearch. If there is an item with that name in the Applications folder, delete it, and if you wish, replace it with the genuine article from mplayerx.org.
    This malware is often found on illegal websites that traffic in pirated content such as movies. If you, or anyone else who uses the computer, visit such sites and follow prompts to install software, you can expect more of the same, and worse, to follow. Never install any software that you downloaded from a bittorrent, or that was downloaded by someone else from an unknown source.
    In the Security & Privacy pane of System Preferences, select the General tab. The radio button marked Anywhere  should not be selected. If it is, click the lock icon to unlock the settings, then select one of the other buttons. After that, don't ignore a warning that you are about to run or install an application from an unknown developer.
    Still in System Preferences, open the App Store or Software Update pane and check the box marked
              Install system data files and security updates
    if it's not already checked.

  • Problems with JSP pages and BC objects

    Hi all. I have a new problem. I'm creating an application based on a database, using BC and JSP pages. I created entity objects from tables and then view objects. I put these view objects in an Application Module. When I test my view objects from This Application Module all works, but when I create a new JSP, I can't drag and drop any view objects in it. I'm using Jdev 10.1.2.
    Is there any one who can help me?
    Thank you,
    Caterina.

    I'm using the MVC pattern, so I have a Model directory that contains my BC, and a ViewController directory in which I want to create JSP pages with a Struts page flow.

  • Problem with serial read and write-unab​le to refresh the port number

    I use the advanced serail write and read example. Build the application, copy the application to another laptop with labview run time engine 2009 installed. And I connect my serial device via a serial to usb adaptor. The problem is that VISA source number is always com1, even I refresh it. But in my case the device via adpator should be com5. I can get the hyperterminal working using com5. Something must be wrong. The strange thing is that there are three laptops, I did the same processdure with each one, one of them are working, the other two won't. Anybody came cross same problems before? Many thanks.

    Hi,
    I think you didn't have installed the Visa Run time engine on this computer.
    best regards,
    V-F

  • Applescript problems with character offsets and embedded objects in Pages

    https://discussions.apple.com/thread/2550810?start=0&tstart=0
    The above discussion is archived, but I've noticed a problem witht he solution it proposes.
    Essentially, the problem seems to be that the character offset of a selection becomes either inaccessible or out of sync when embedded objects are present in the file.
    The following document can be used to demonstrate:
    http://images.apple.com/support/pages/docs/ePub_Best_Practices_EN.zip
    I've slightly modified the script fromt he previous thread, so here's my own script:
    tell front document of application "Pages"
              set C to character offset of (get selection)
              set N to 0
              repeat with P in (get character offset of paragraphs)
                        if P > C then exit repeat
                        set N to N + 1
      select paragraph (N + 1)
              end repeat
              N
    end tell
    This script is supposed to select the next paragraph in a document, when given a selection. The intention is to call it recursively to get each paragraph of the document in turn.
    At the start of the document, it functions correctly, however when it gets to the embedded pictures, lines and table of contents, things start to break. This wouldn't be so bad, because I could simply ignore paragraphs that contains those embedded objects, but the real problems arise in the normal text below these objects.
    If you place the cursor on the 3rd page of that document, in an ordinary paragraph, for example, this script will simply return the same paragraph over and over. The reason for this is that the character offset of the paragraphs is being thrown off, so the if statement gets hit too early. You can also see this if you look at the character offsets of the word "Introduction" in the heading at the top of the 3rd page. You'll notice that the character offset is duplicated for a couple of letters, and is out of sync with the index of the character itself.
    What I need is a script that will take a selection (of any type), and simply return the correct index of the paragraph containing it every time. It doesn't seem like a difficult thing to do, and since the paragraphs are accessible by index, they should be able to return their index to the user. I have a feeling Apple need to add this functionality to the Pages Applescript dictionary, and they definitely need to fix the bug where the character offsets go out of sync after embedded objects. These are really quite bad problems.

    Hi,
    Pierre L. wrote:
    I have tested it with the document referred to by andyboyd. When the first word (“Introduction”) of the first paragraph of page 3 is selected, your script returns {10}, while it returns {12} when the second word (“to”) of the same paragraph is selected.
    Message was edited by: Pierre L.
    Thanks Pierre.
    Ok, the error is that I mixed the variable N and N1, during the renaming of variables
    return N - 1  must be return N1 - 1 -- return the index
    Here the corrected script :
    set indexList to my getIndexOfLinesInSelection()
    on getIndexOfLinesInSelection()
       script o
          property parOffsetList : {}
          on getIndex(C)
             tell application "Pages" to tell front document
                set parOffsetList to character offset of paragraphs
                set tc to count parOffsetList
                repeat with N from 1 to tc
                   if N = tc then return tc -- it's the last paragraph
                   if (item N of parOffsetList) > C then
                      set N1 to N
                      repeat -- check the  character offset of the selected line
                         if N1 = tc then return tc -- it's the last paragraph
                         select paragraph N1 -- select next paragraph
                         set sel to (get selection)
                         if class of sel is list then
                            repeat with aItem in sel --  this line contains text and object
                               try
                                  if character offset of first character of aItem > C then return N1 - 1 -- return the index
                                  exit repeat -- else  character offset of the selection <= C , exit the repeat
                               end try -- error,aItem is not valid, continue the repeat
                            end repeat
                         else
                            try
                               if (character offset of first character of sel) > C then return N1 - 1 -- return the index
                            end try
                         end if
                         set N1 to N1 + 1
                      end repeat
                   end if
                end repeat
             end tell
          end getIndex
       end script
       tell application "Pages" to tell front document
          set sel to (get selection)
          if class of sel is list then -- selection contains object or  (Non-Continuous selection in the same line or in  différents lines).
             set charOffsetList to {}
             repeat with aItem in sel
                try
                   set end of charOffsetList to (character offset of aItem) -- get character offset of  the  valid item
                end try
             end repeat
          else -- insertion point or  the first line in continous text selection
             set charOffsetList to {character offset of sel}
          end if
          if charOffsetList is {} then return {} --  no valid item in the selection
          set indexList to {}
          repeat with C in charOffsetList
             set r to o's getIndex(C)
             if r is not in indexList then set end of indexList to r
          end repeat
          return indexList
       end tell
    end getIndexOfLinesInSelection

  • Problem with sorting involving user defined types and reports

    Hello!
    I have a problem with sorting involving Reports and user defined objet types.
    I have created the following object types
    CREATE TYPE type_balance_compte AS OBJECT
    NUM_CPT_SEQ NUMBER(8)
    ,NUM_CPT VARCHAR2(35)
    CREATE TYPE TB_type_balance_compte IS TABLE OF type_balance_compte
    At the reports query I use:
    SELECT ...
    FROM table(cast(test_pkg.balance_comptes(:P_num_soc) as TB_type_balance_compte)) c
    The procedure balance_comptes will retrieve data from various tables into the type.
    The report is ordered by a certain string field that usually contains characters and numbers.
    I need to have numbers always before characters, meaning the data should come in this order in the report for example:
    0
    1
    A
    B
    So, before the report query, I have placed a call to DBMS_SESSION.SET_NLS( 'nls_sort', 'binary' ) to guarantee NLS_SORT in case it is originally set to FRENCH.
    The problem here is that even after this call, I have the report ordered like this
    A
    B
    0
    1
    And not the numbers before as it should be.
    To try and find out where the problem was, I have created a table to use instead of the object type described above. In this case, it worked correctly. So all I know by now is that is has something to do with the type or cast, but what exactly? Does anybody now how to solve this without using a table?
    Many thanks
    Ariadne

    I have placed a call to DBMS_SESSION.SET_NLS( 'nls_sort', 'binary' ) why not order directly then:
    SQL> select *
          from table (sys.dbms_debug_vc2coll ('A', 1, '5', 'C', 'a'))
    order by nlssort (column_value, 'NLS_SORT = binary')
    COLUMN_VALUE                                                                   
    1                                                                              
    5                                                                              
    A                                                                              
    C                                                                              
    a                                                                              
    5 rows selected.?

  • Hi I have had problems with photo's and films going onto a 2010 Apple classic MP3.  Have managed to sort photos but it still refuses to copy the films purchased. It comes up with not copied cannot be played on this ipod.

    Hi have had problems with photo's and films going onto a 2010 Apple Classic mp3. Have managed to sort photo's but the films won't copy and comes up with message videos not copied cannot be played on this ipod

    razzbust wrote:
    ...but the films won't copy and comes up with message videos not copied cannot be played on this ipod
    Self explanatory.
    You could try creating an iPod version of the films.
    Use CTRL and B to display the Menu bar shown above. Alternatively, use the ALT key, followed by the F key, the W key and finally the I (eye) key - that's (menu)/File/Create New Version/Create iPod or iPhone version.

  • I have a problem with my bluetooth and Wi-Fi, it seems not to connect and just keep searching

    i have a problem with my bluetooth and Wi-Fi, it seems not to connect and just keep searching

    Hello there, charles.
    The following Knowledge Base article offers up some great information and links in regards to things that can interfere with both Bluetooth and Wi-Fi:
    Wi-Fi and Bluetooth: Potential sources of wireless interference
    http://support.apple.com/kb/ht1365
    Additionally the following articles offer specific steps for each:
    iOS: Troubleshooting Bluetooth connections
    http://support.apple.com/kb/TS4562
    and
    iOS: Troubleshooting Wi-Fi networks and connections
    http://support.apple.com/kb/ts1398
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • Hot Data Block with concurrent read and write

    Hi,
    This is from ADDM Report.
    FINDING 8: 2% impact (159 seconds)
    A hot data block with concurrent read and write activity was found. The block
    belongs to segment "SIEBEL.S_SRM_REQUEST" and is block 8138 in file 7.
    RECOMMENDATION 1: Application Analysis, 2% benefit (159 seconds)
    ACTION: Investigate application logic to find the cause of high
    concurrent read and write activity to the data present in this block.
    RELEVANT OBJECT: database block with object# 73759, file# 7 and
    block# 8138
    RATIONALE: The SQL statement with SQL_ID "f1dhpm6pnmmzq" spent
    significant time on "buffer busy" waits for the hot block.
    RELEVANT OBJECT: SQL statement with SQL_ID f1dhpm6pnmmzq
    DELETE FROM SIEBEL.S_SRM_REQUEST WHERE ROW_ID = :B1
    RECOMMENDATION 2: Schema, 2% benefit (159 seconds)
    ACTION: Consider rebuilding the TABLE "SIEBEL.S_SRM_REQUEST" with object
    id 73759 using a higher value for PCTFREE.
    RELEVANT OBJECT: database object with id 73759
    SYMPTOMS THAT LED TO THE FINDING:
    SYMPTOM: Wait class "Concurrency" was consuming significant database
    time. (4% impact [322 seconds])
    what does it mean by hot block with concurrent read and write??
    is rebuilding the table solves the problem as per addm report?

    Hi,
    You must suffer from buffer busy waits.
    When a buffer is updated, the buffer will be latched, and other sessions can not read it or write it.
    You must have multiple sessions reading and writing that one block.
    Recommendation 2 results in fewer records per block, so less chance multiple sessions are modifying and reading 1 block. It will also result in a bigger table.
    The recommendation doesn't make sense for tablespaces with segment storage management auto, as for those tablespaces pctfree does not apply.
    Buffer busy waits will also occur if the blocksize of your database is set too high.
    Sybrand Bakker
    Senior Oracle DBA

  • Problem with the MenuBar and how can i delete a own component out of the storage

    Hello,
    I opened this thread in the category "Flex Builder 2", but
    under this category my questions fit better.
    I have a problem with the MenuBar and a question to delete a
    component out of storage.
    1. We have implemented the MenuBar, which was filled
    dynamically with XML data.
    Sporadically it will appear following fault, if we "mousover"
    the root layer.
    RangeError: Error #2006: Der angegebene Index liegt
    außerhalb des zulässigen Bereichs.
    at flash.display::DisplayObjectContainer/addChildAt()
    at mx.managers::SystemManager/
    http://www.adobe.com/2006/flex/mx/internal::rawChildren_addChildAt()
    at mx.managers::SystemManager/addChild()
    at mx.managers::PopUpManager$/addPopUp()
    at mx.controls::Menu/show()
    at mx.controls::MenuBar/::showMenu()
    at mx.controls::MenuBar/::mouseOverHandler()
    Here a abrid ged version of our XML to create the MenuBar:
    <Menuebar>
    <menu label="Artikel">
    <menu label="Artikel anlegen" data="new_article" />
    <menu label="Artikel bearbeiten" data="edit_article" />
    <menu label="Verpackung">
    <menu label="Verpackung anlegen" data="new_package" />
    <menu label="Verpackung bearbeiten" data="edit_package"
    />
    </menu>
    <menu label="Materialgruppe">
    <menu label="Materialgruppe anlegen"
    data="new_materialgroup" />
    <menu label="Materialgruppe bearbeiten"
    data="edit_materialgroup" />
    </menu>
    </menu>
    </Menuebar>
    It is a well-formed XML.
    2. Delete a component out of storage
    We have some own components (basically forms), which will be
    created and shown by an construct e.g.
    var myComponent : T_Component = new T_Component ;
    this.addChild(myComponent)
    Some of our forms will be created in an popup. On every call
    of the popup, we lost 5 mb or more, all childs on the windows will
    be removed by formname.removeAllChild();
    What cann we do, that the garbage collector will dispose this
    objects.
    Is there a way to show all objects with references (NOT
    NULL)?
    I have read in the Flex Help, that
    this.removeChild(myComponent) not delete the form and/or object out
    of the storage.
    Rather the object must be destroyed.
    It is sufficient to call delete(myComponent) about remove
    this object out of the storage as the case may be that the
    garbage-collector remove this object at any time?
    Or how can I destroy a component correctly. What happens with
    the widgets on this component e.g. input fields or datagrids?
    Are they also being deleted?
    Thanks for your help.
    Matze

    If you mena the "photo Library" then you cannot delete it.
    This is how iphone handles photos.  There are not two copies.  There a re simply two places from which to access the same photos.  ALL photos synced to iphone can be accessed via Photo Library.  Those same pics can be accessed via their individual folder.

  • Problems with HP printer and PSE 11 (was bill v)

    When using my HP 7020e photosmart printer and Adobe photoshop elements 11, I get a very small white border on the prints. I have set for borderless printing. Adobe says the print size is 4.2 x 6.18 instead of 4 x 6. Any suggestions?

    I had already set it to borderless but it still prints a very small white 
    border. HP had no solution. I am ready to send the printer back to them.
    In a message dated 1/14/2014 5:47:22 A.M. Eastern Standard Time, 
    [email protected] writes:
    Re:  Problems with HP printer and PSE 11 (was bill v)
    created by hyadav (http://forums.adobe.com/people/hyadav)  in Photoshop 
    Elements - View the full  discussion
    (http://forums.adobe.com/message/6010537#6010537)

  • Problems with captivate 8 and windows 8

    I´m using captivate 8 and windows 8, and I am having problems with the visualization and publication of my projects. For visualization, there is a message of an error with syntax of the files ou directory, and nothing happens. For publication, I can´t see the project published in the browser. It opens only a text file, with the codes. Is there anyone thar can help me with that?

    Acrobat 8 is not certified for Win7, particularly the x64 version. If you got the installation to go, the first step is to update AA8 to at least AA8.2. The x64 with XP required at least AA8.2 and I suspect that has not changed. I would suggest updating to the latest, either from the help menu (until no more updates are available) or by downloading the updates from the adobe.com>downloads page. For the latter, download ALL updates after your current version and install them in ORDER. They are not cummulative in most cases. You only need to reboot after the final update. The updates may get you going. If not, you may simply have to upgrade to AA9 or search for what others have been able to do in your situation.

  • Problem with create universe on Business Objects XI 3.1 base on SAP Query

    Hello,
    I have a problem with create universe on Business Objects XI 3.1 base on SAP Query.
    The problem is hierarchy. Massage on Busines Objects is :
       OWBS_ELEMT__ISTKOSZT(cube ICPC01/BEX_ICOC01):Exception condition  "HIERARCHY NOT FOUND" raised.(WIS 10901) 
    Query in BEX run OK.
    Best regards.
    Ela.

    Hello,
    Thanks for response.
    When I run BEX QUERY, all works OK.
    All hierarchies was created and activated  on system BW.
    This situation appears after upgrade BW to SAP NetWeaver 7.3.
    Before upgrade I created universe without any problems.
    Regards Ela

Maybe you are looking for

  • Static at 16k on equalizer?

    Alright I use pretty high grade headphones. I have them plugged into my reciever. When I watch a movie and a quiet scene comes up I hear static. It stands out alot. I played around with equalizer and it was at 16k. I turn it down and static goes down

  • Creation of inforecord

    hello all, i have created a program to create inforecord using BDC. I do not pass the plant as I do not want it. but finally when the inforecord is created, it is created with plant. table EINE has plant also. do you have any guess as to how this is

  • Webcenter site 11.1.1.8 -An internal error occurred during: "Sync to Workspace".

    Hi , I am getting this error while sync to workspace. I have cleared installation of eclipse and try it again but still same issue . java.lang.RuntimeException: Exception thrown while setting the following URI values: CS_INSTALLDIR=C:\Oracle\webcente

  • Kernel programming using Java

    I'm currently doing a research in computer security and would like to develop a system which can deal directly to linux kernel in order to enhance the security. During my research I found that Java is a type-safe language which is more secure if I de

  • N95-2 Surely will show contact pic on text or call...

    Hi really pleased with my new N95 8gig BUT surely I should be able to see a contacts thumbnail when a text comes in or when a call comes? Hate the fact it just says 1 message and you have to see who etc first? All my old Nokias did this and they were