Using a Comparable Class with Treeset, creating counter in comparable clas

http://rafb.net/paste/results/jibQzk63.html - comparable http://rafb.net/paste/results/Noahue63.html - loading
http://rafb.net/paste/results/re1Swn60.html - contents of .txt file * sorry the paste is weird lol.
Trying to List word count in alphabetical order - Already did that
Having a counter so it counts the number of time that specfic word appeared in the txt file - This is my problem I don't know where to add the counter in my comparable class so it stores a number and adds everytime that same word appears. ex. "and 7" the word "and" appeared 7 times in the .txt file
so if some1 could help me, would be apperciated. I've like tried everything and getting the opposite results.

That's just the issue I'm having. My sample code functions as long as the parameterized type being compared isn't Comparable. For example, changing the type to A<Integer,String> works fine.
I think I may have discovered why this is the case. By declaring A<Comparable,String>, I am implying that the first parameterized type (call it T) is Comparable<T>. As a result, what I need is an A<Comparable<Comparable>, String>; that is, anything which is comparable must be able to be compared to the object. Since Integer is only Comparable<Integer>, it cannot be compared to all Comparable objects and therefore doesn't meet the requirements.
I'm not used to looking the other way on the inheritance tree. :)
The original trouble I had with this came from when I was passing a hash code generator into a piece of source and I needed to compare the hashes. The only guarantee I have regarding the hashes is that they are Comparable and I was putting them in a similar Pair structure. I then wanted to build a comparator to compare them but, since they're Comparable<?>, I can't know to what they can be compared... so I'll have to change the contract on the code. ;)
Thanks. Cheers. :)

Similar Messages

  • How to use JAXB generated classes with SOAP

    hello,
    I have a library of JAXB generated classes for my web service. There is a Java class for each web method defined in my schema. For example, my getLocation method is mapped to GetLocation.class.
    However my web service is SOAP based, so I am having to manually strip off the SOAP elements to be able to unmarshall the getLocation xml to a GetLocation class.
    I am noticing a disconnect between JAXB and other Java SOAP and RPC libraries. Does anyone know how to create a JAXB class for SOAP Envelopes and Bodys? Does anyone have any ideas how to incorporate the existing Java web service libraries with JAXB?
    Thanks in advance.

    Have you found a method to integrate SAAJ and JAXB? Or
    is better to use SAAJ only ?If I had to choose I'd go with SAAJ. It seems to me that's theoretically possible to use JAXB classes with SAAJ but I imagine if it is possible it would be a big pain in the ass.

  • Using Java 6 classes with Java 5

    I ran into a little problem with the portability of Java (ironic eh?) across computers. The program I wrote on my home computer uses GroupLayout for the GUI. However, much to my surprise, the computers at my school only had Java 5 installed so the program could not run (GroupLayout is a class found only in Java 6). Is there any way to somehow package the GroupLayout class into my program?

    C_Zhao wrote:
    I ran into a little problem with the portability of Java (ironic eh?) across computers.Not as ironic as you might think.
    The program I wrote on my home computer uses GroupLayout for the GUI. However, much to my surprise, the computers at my school only had Java 5 installed so the program could not run (GroupLayout is a class found only in Java 6). Is there any way to somehow package the GroupLayout class into my program?Technically, yes, but I'd imagine that rewriting your code to use a different layout manager (such as one of those available in J2SE 5) would be quicker / easier. In fact, I'm almost willing to guarantee that refactoring would be easier than repackaging.

  • One method used in two classes

    Hi
    I have one method in class A and I need to use it (only this method) in class B. what should I do? Should I create subclass within class A with this method, and then use it in class B or create completely different class C with only this method?
    Thanks
    waso

    It's a good idea to use Java conventions about cAsE: especially since boolean and Boolean are different beasts.
    So:
    public class MyExample {
        public boolean example() {
            System.out.println("My example");
            return true;
    }You use it in some other class B like this:
    class B {
        void someMethod() {
            MyExample eg = new MyExample();
            boolean result = eg.example();
            System.out.println("example() returned " + result + " (as expected!)");
    }There's no subclassing ("in" A or elsewhere).
    This is a bit of a contrived example, because example() always returns the same thing. eg is initialised as an instance of MyExample but that class has no state so the method is effectively static. If MyExample had state and the method call did something genuine involving this state, then things would get interesting - and it is precisely then that subclassing, extracting someMethod() into some other class, or inlining it where it was used would make no sense.
    Edited by: pbrockway2 on Jul 12, 2008 9:26 PM

  • Why can we only use 1 release class for overall Release of Purchase Req?

    Hi,
    After realizing that it would be beneficial to use more than one release class for overall release of Purchase Requisition with classification, in use with release groups for overall release, I now ask if someone knows why SAP has chosen to only allow 1 release class for overall release of Purchase Requisition?
    In my scenario I would like Release group US, used for release strategies for US-plant to be able to use 1 release class with a specific set of characteristics.
    For example class REL_PREQ_CLASS_OVERALL_VALUE_IN_USD including a characteristic PR_TOTVAL_USD looking at CEBAN-GFWRT. The chosen currency for this characteristic would be USD.
    I would then like to allow Release group FR, used for release strategies for FRANCE-plant to use another release class with another set of characteristics.
    For example class REL_PREQ_CLASS_OVERALL_VALUE_IN_EUR including a characteristic PR_TOTVAL_EUR looking at CEBAN-GFWRT. The chosen currency for this characteristic would be EUR.
    In this way the release strategies for the respective release groups US and FR, could maintain their overall limit values in their respective release strategies in their own currencies.
    1. Observe that I do not want to use the same Release class for both release groups for overall release, even though I know that this is currently the only allowed option, as far as I've understood.
    2. Observe that I do not want to specify the two characteristics PR_TOTVAL_USD and PR_TOTVAL_EUR for overall value in the same release class, as this would lead to double maintenance for a large number of release strategies. Also consider the maintenance when new countries with new currencies want release strategies.
    3. Observe that I only want to use overall release.
    What I'm trying to avoid is having to continuously translate local business USD overall value limits to limits in the currency chosen for the overall value characteristic. If this for example is specified in DKK, this would lead to a need to adjust the overall value limits as soon as the exchange rate between USD and DKK changes in the system.
    Please consider this simple example:
    Local requirement is that USD purchase requisitions should be blocked when the USD value is above 1000 USD. However in my release strategy I would have to maintain a value of >5365 DDK, if DKK is chosen as the currency for overall characteristic.(e.g exchange rate 5,365).
    Next month the currency exchange rate in the system between USD and DKK has changed, and therefore I would have to go into CL24N and maintain the value to reflect the new exchange rate between USD and DKK. Lets say it has gone up to 5,435. I would now have to maintain a value of > 5435 DKK in my release strategy to correctly reflect the local business requirement of 1000 USD.
    So if anyone could please explain why SAP has taken the decision to make the Release class for overall release client specific that would be much appreciated and awarded accordingly. Also if you have any suggestion on how I could obtain the above scenario on maintaning overall value limits in different currencies than that would be awarded to.
    BR Jakob F. Skott

    You can give feed back to Apple from the iTunes drop-down menu in the iTunes menu bar..
    You can also contact the iTS Customer Service from the links on this page - http://www.apple.com/support/itunes/store/
    MJ

  • What is '&' used in message class

    Hi,
    What is '&' used in message class with the message no in SE91.
    Give me details idea on this.
    Best Regards,
    Chini

    If you use '&' operator in your message, then you can pass the text/literals whatever you want to get display in the message.
    For example,
    In a message clase zmsg, there is a message like this...
    018 Table & not exist
    you can call this message from your program by passsnig the table name in to this message...
    For example,
    ztablename = 'BUT000'.
    Message e018(zmsg) with ztablename.
    Filling Message Texts Dynamically *
    Message texts in table T100 can contain up to four ampersand characters (&) as placeholders. You can replace these at runtime using the WITH addition in the MESSAGE statement:
    MESSAGE ... WITH f1 ... f4.
    The contents of fields f1 ... f4 are then inserted sequentially into the message text in place of the placeholders.

  • Real Estate Indicator use in Asset Class

    Hi
    I would like to know what is the use of Real Estate Indicator in Asset Class.
    Thanks.

    Hi
    If u select assect indicator in asset class and after some of the settings in real estate module.  whenever  you create asset by using this asset class, system will create real estate object directly.
    Don't forge to assign points.
    Regards.

  • Comparing a class with Class-Object

    Hi there:
    I receive a Class-Object and have to compare it
    with a class, for example:
    public boolean stringClass(Class cl) {
      if (cl.equals("".getClass))
        return true;
      else
        return false;
    }I don't like this because in case of complex objects I have
    to create this object only for comparing, it's very inefficient:
    public boolean specialClass(Class cl)
       return cl.equals((new Special(<many parameters .. >)).getClass());
    }Any idea? Am I simply confused to see a clear solution?
    I will prefer something like this:
    if ( cl == Special.getClass())Thanx
    Andreas

    If you have an object, for example a String object, then you can check if this object is really a String:
    Object o = new String("");
    if (o instanceof String) {
      System.out.println("The object is a String");
    }Can you use that, or do you really want to test if a Class object is the name of a given class?
    Class cl = String.class;
    if (cl.getName().equals("java.lang.String")) {
      System.out.println("String Class");
    }

  • Error while creating vendor bank details using MAINTAIN_BAPI of class VMD_ei_api

    hi, iam using maintain_bapi of class vmd_ei_api for bank details creation at the time of vendor creation. but im getting error: ' Invalid address:bank Country missing'.please suggest
    *    *** Bank details***************************************
        DATA: lt_bankdetails TYPE TABLE OF cvis_ei_cvi_bankdetail,
              ls_bankdetails TYPE cvis_ei_cvi_bankdetail.
        ls_bankdetails-data_key-banks = 'DE'. "Bank Country
        ls_bankdetails-data_key-bankl = 'BEBEDEBB'.     "Bank Key..
        ls_bankdetails-data_key-bankn = '3538174400' ."Bank account number.
        ls_bankdetails-data-bvtyp     = 'USA'.
        ls_bankdetails-data-bkref     = 'BEN'.           "Reference details.
        ls_bankdetails-datax-bvtyp     = 'X'.
        ls_bankdetails-datax-bkref     = 'X'.           "Reference details.
        ls_bankdetails-task            = 'I'.
        ls_bankdetails-data-iban      = 'DE24100200003538174400'.
        ls_bankdetails-datax-iban      = 'X'.
        APPEND  ls_bankdetails TO lt_bankdetails.
    *CLEAR : ls_bankdetails.
    *    ls_bankdetails-datax-iban      = 'X'.
    *   APPEND  ls_bankdetails TO lt_bankdetails.
    *  Inserting bank details,,,,
        ls_bank-bankdetails = lt_bankdetails[].
        ls_bank-current_state = ''.
        ls_vendors-central_data-bankdetail = ls_bank.
    And second question how/which method to use from this class to update bank details latter. Is it possible after creating vendor with mandatory fields and then update bank details?

    Hi Abhijeet,
    please check in transaction FI01, about your data consistencies. You can use this wiki help in terms of Address, it it found any useful facts for you
    Address Checks - Business Address Services (BC-SRV-ADR) - SAP Library

  • Re: How do you create and use "common" type classes?

    Hi,
    You have 2 potential solutions in your case :
    1- Sub-class TextNullable class of Framework and add your methods in the
    sub-class.
    This is the way Domain class work. Only Nullable classes are sub-classable.
    This is usefull for Data Dictionary.
    The code will be located in any partition that uses or references the supplier
    plan.
    2- Put your add on code on a specific class and instanciate it in your user
    classes (client or server).
    You could also use interface for a better conception if needed. The code will
    also be in any partition that uses or references the supplier plan where your
    add on class is located.
    If you don't want that code to be on each partition, you could use libraries :
    configure as library the utility plan where is your add-on class.
    You can find an example of the second case (using a QuickSort class,
    GenericArray add-on) with the "QuickSort & List" sample on my personal site
    http://perso.club-internet.fr/dnguyen/
    Hope this helps,
    Daniel Nguyen
    Freelance Forte Consultant
    http://perso.club-internet.fr/dnguyen/
    Robinson, Richard a &eacute;crit:
    I'm relatively new to forte and I'd like to know how can you handle utility
    type classes that you want to use through out your application? Ideally
    what I want is a static class with static methods.
    Let's say that I have a StringUtil class that has a bunch of methods for
    manipulating strings.
    My problem is that we have code that runs on the client and code that runs
    on the server. Both areas could use the StringUtil class, but from what I
    understand, I have to create StringUtil in a plan and then create a server
    object of type StringUtil. The server object will eventually get assigned
    to a partition. That's not good since I really want the server object to
    physically reside at the server end and at the client end. (Actually, I
    don't want a server object, I just want to invoke a static method of a
    static class).
    Any clues on how to solve this problem would be appreciated.
    Also, what is the url at Sage-it that has a summary of all emails that have
    been posted to [email protected]? Perhaps this question has been
    answered previously.
    Thanks in advance
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>-
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Hi Richard,
    Your question about "utility classes" brings up a number of issues, all of
    which are important to long-term success with Forte.
    There is no such thing as a static method (method that is associated with a
    class but without an implicit object reference - this/self/me "pointer") in
    TOOL, nor is there such thing as a global method (method not associated
    with a class at all). This is in contrast to C++, which has both, and
    Java, which has static methods, but not global classes. Frequently, Forte
    developers will write code like this:
    result, num : double;
    // get initial value for num....
    tmpDoubleData : DoubleData = new;
    tmpDoubleData.DoubleValue = num;
    result = tmpDoubleData.Sqrt().DoubleValue;
    tmpDoubleData = NIL; // send a hint to the garbage collector
    in places where a C++ programmer would write:
    double result, num;
    // get initial value for num....
    result = Math::Sqrt(num);
    or a Java programmer would write:
    double result, num;
    // get initial value for num....
    result = Math.sqrt(num);
    The result of this is that you end up allocating an extra object now and
    then. In practice, this is not a big deal memory-wise. If you have a
    server that is getting a lot of hits, or if you are doing some intense
    processing, then you could pre-allocate and reuse the data object. Note
    that optimization has its own issues, so you should start by allocating
    only when you need the object.
    If you are looking for a StringUtil class, then you will want to use an
    instance of TextData or TextNullable. If you are looking to add methods,
    you could subclass from TextNullable, and add methods. Note that you will
    still have to instantiate an object and call methods on that object.
    The next issue you raise is where the object resides. As long as you do
    not have an anchored object, you will always have a copy of an object on a
    partition. If you do not pass the object in a call to another partition,
    the object never leaves. If you pass the object to another partition, then
    the other partition will have its own copy of the object. This means that
    the client and the server will have their own copies, which is the effect
    you are looking for.
    Some developers new to Forte will try to get around the lack of global
    methods in TOOL by creating a user-visible service object and then calling
    methods on it. If you have a general utility, like string handling, this
    is a bad idea, since a service object can reside only on a single
    partition.
    Summary:
    * You may find everything you want in TextData.
    * Unless you anchor the object, the instance will reside where you
    intuitively expect it.
    * To patch over the lack of static methods in TOOL, simply allocate an
    instance when required.
    Feel free to email me if you have more questions on this.
    At the bottom of each message that goes through the mailing list server,
    the address for the list archive is printed:
    http://pinehurst.sageit.com/listarchive/.
    Good Luck,
    CSB
    -----Original Message-----
    From: Robinson, Richard
    Sent: Tuesday, March 02, 1999 5:44 PM
    To: '[email protected]'
    Subject: How do you create and use "common" type classes?
    I'm relatively new to forte and I'd like to know how can you handle utility
    type classes that you want to use through out your application? Ideally
    what I want is a static class with static methods.
    Let's say that I have a StringUtil class that has a bunch of methods for
    manipulating strings.
    My problem is that we have code that runs on the client and code that runs
    on the server. Both areas could use the StringUtil class, but from what I
    understand, I have to create StringUtil in a plan and then create a server
    object of type StringUtil. The server object will eventually get assigned
    to a partition. That's not good since I really want the server object to
    physically reside at the server end and at the client end. (Actually, I
    don't want a server object, I just want to invoke a static method of a
    static class).
    Any clues on how to solve this problem would be appreciated.
    Also, what is the url at Sage-it that has a summary of all emails that have
    been posted to [email protected]? Perhaps this question has been
    answered previously.
    Thanks in advance

  • Using analytical function - value with highest count

    Hi
    i have this table below
    CREATE TABLE table1
    ( cust_name VARCHAR2 (10)
    , txn_id NUMBER
    , txn_date DATE
    , country VARCHAR2 (10)
    , flag number
    , CONSTRAINT key1 UNIQUE (cust_name, txn_id)
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9870,TO_DATE ('15-Jan-2011', 'DD-Mon-YYYY'), 'Iran', 1);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9871,TO_DATE ('16-Jan-2011', 'DD-Mon-YYYY'), 'China', 1);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9872,TO_DATE ('17-Jan-2011', 'DD-Mon-YYYY'), 'China', 1);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9873,TO_DATE ('18-Jan-2011', 'DD-Mon-YYYY'), 'Japan', 1);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9874,TO_DATE ('19-Jan-2011', 'DD-Mon-YYYY'), 'Japan', 1);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9875,TO_DATE ('20-Jan-2011', 'DD-Mon-YYYY'), 'Russia', 1);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9877,TO_DATE ('22-Jan-2011', 'DD-Mon-YYYY'), 'China', 0);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9878,TO_DATE ('26-Jan-2011', 'DD-Mon-YYYY'), 'Korea', 0);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9811,TO_DATE ('17-Jan-2011', 'DD-Mon-YYYY'), 'China', 0);
    INSERT INTO table1 (cust_name, txn_id, txn_date,country,flag) VALUES ('Peter', 9854,TO_DATE ('13-Jan-2011', 'DD-Mon-YYYY'), 'Taiwan', 0);
    The requirement is to create an additional column in the resultset with country name where the customer has done the maximum number of transactions
    (with transaction flag 1). In case we have two or more countries tied with the same count, then we need to select the country (among the tied ones)
    where the customer has done the last transaction (with transaction flag 1)
    e.g. The count is 2 for both 'China' and 'Japan' for transaction flag 1 ,and the latest transaction is for 'Japan'. So the new column should contain 'Japan'
    CUST_NAME TXN_ID TXN_DATE COUNTRY FLAG country_1
    Peter 9811 17-JAN-11 China 0 Japan
    Peter 9854 13-JAN-11 Taiwan 0 Japan
    Peter 9870 15-JAN-11 Iran 1 Japan
    Peter 9871 16-JAN-11 China 1 Japan
    Peter 9872 17-JAN-11 China 1 Japan
    Peter 9873 18-JAN-11 Japan 1 Japan
    Peter 9874 19-JAN-11 Japan 1 Japan
    Peter 9875 20-JAN-11 Russia 1 Japan
    Peter 9877 22-JAN-11 China 0 Japan
    Peter 9878 26-JAN-11 Korea 0 Japan
    Please let me know how to accomplish this using analytical functions
    Thanks
    -Learnsequel

    Does this work (not spent much time checking it)?
    WITH ana AS (
    SELECT cust_name, txn_id, txn_date, country, flag,
            Sum (flag)
                OVER (PARTITION BY cust_name, country)      n_trx,
            Max (CASE WHEN flag = 1 THEN txn_date END)
                OVER (PARTITION BY cust_name, country)      l_trx
      FROM cnt_trx
    SELECT cust_name, txn_id, txn_date, country, flag,
            First_Value (country) OVER (PARTITION BY cust_name ORDER BY n_trx DESC, l_trx DESC) top_cnt
      FROM ana
    CUST_NAME      TXN_ID TXN_DATE  COUNTRY          FLAG TOP_CNT
    Fred             9875 20-JAN-11 Russia              1 Russia
    Fred             9874 19-JAN-11 Japan               1 Russia
    Peter            9873 18-JAN-11 Japan               1 Japan
    Peter            9874 19-JAN-11 Japan               1 Japan
    Peter            9872 17-JAN-11 China               1 Japan
    Peter            9871 16-JAN-11 China               1 Japan
    Peter            9811 17-JAN-11 China               0 Japan
    Peter            9877 22-JAN-11 China               0 Japan
    Peter            9875 20-JAN-11 Russia              1 Japan
    Peter            9870 15-JAN-11 Iran                1 Japan
    Peter            9878 26-JAN-11 Korea               0 Japan
    Peter            9854 13-JAN-11 Taiwan              0 Japan
    12 rows selected.

  • Did the Java Writers Get a Little Happy with Memory Use in String class?

    I mean that question half jokingly.
    Taking a look at the String class code, I saw the following (below).
    Why is there an int for offset and an int for count?
    String is immutable, why not just return value.length for the count?
    And what is the offset for?
    Thanks!
    public final class String
        implements java.io.Serializable, Comparable<String>, CharSequence
        /** The value is used for character storage. */
        private final char value[];
        /** The offset is the first index of the storage that is used. */
        private final int offset;
        /** The count is the number of characters in the String. */
        private final int count;
        /** Cache the hash code for the string */
        private int hash; // Default to 0PS: a second look kinda verifies it too.
    in the constructor ,count is even defined as value.length.
        public String(char value[]) {
         int size = value.length;
         this.offset = 0;
         this.count = size;
         this.value = Arrays.copyOf(value, size);
        }

    You don't get the choice. The arrays are shared
    whenever you do substring.Yea, thats my point. I think most Strings are unique.
    Id be very surprised if even 2% of all String use was
    a result of a substring.The wrapper classes use it for parsing.
    File uses it for getName and getParent.
    String uses it for trim.
    Class uses it for resolving names.
    Regex uses it.
    etc. ...
    Now, I don't know what percentage of usage all that amounts to, but it IS heavily used.
    So your desire to gain the 2 bytes back would cost enough byte every time substring is used that it might end up costing far more than the 8 bytes you save.

  • Problem to use SAPServer Class with load balancing

    Hello,
    We use the SAPServer Class from SAP .Net Connector 1.0.
    On our system, we want to start the RFC Server to use the logon group.
    I didn't find how to use ServerMessage and LogonGroup with one of constructors.
    When we start the SAPServer with the command line -aUSER -gBEAUSR201 -xsapgw10 from the DB server (BEAUSR201) it's Ok,
    but when we start from one of our application Server (for example -aUSER -gBEAUSR213 -xsapgw13 ) it's KO
    we have this message on the trc file.
    ERROR file opened at 20041125 084739 Paris, Madrid, SAP-REL 620,0,1622 RFC-VER 3 683864 MT-SL
    T:13188 ======> Connect to SAP gateway failed
    Connect_PM  TPNAME=USER, GWHOST=BEAUSR214, GWSERV=3314
    LOCATION    CPIC (TCP/IP) on local host
    ERROR       hostname 'BEAUSR214' unknown
    TIME        Thu Nov 25 08:47:39 2004
    RELEASE     620
    COMPONENT   NI (network interface)
    VERSION     36
    RC          -2
    MODULE      ninti.c
    LINE        385
    DETAIL      NiPHostToAddr
    SYSTEM CALL gethostbyname
    COUNTER     1
    What is the solution ?
    Thanks

    Hi,
    The message server and Logon group are there for balancing the load among application servers within a SAP system. You are using the SAPServer class to implement an external RFC server that usually serves the request from SAP servers. So using message server and logon group with an external server doesn't make sense.
    I understand that both your DB server and the application server in question are Windows machine with .NET runtime installed and you started the SAPServer programs directly from Windows command line. If so, the error message for the KO case says that the hostname BEAUSR214 could not be resolved from the application server. I also noticed that the hostname BEAUSR214 in error message doesn't match the hostname BEAUSR213 given in command line.
    Can you ping BEAUSR213 or BEAUSR214 from the application server in concern?
    Regards,
    Guangwei Li

  • How to use class.getResource() to create an ImageIcon

    Hi,
    I am well acquainted with creating and using ImageIcon icons using the ImageIcon constructor
    and putting the image file in a folder called Images which is at the same level as the
    bin and src folders.
    I discovered a demo program, LayeredPaneDemo, that uses class.getResource() to create
    an icon and found that in my eclipse version, the icon's image file was not found when
    I used the original getResource() call but the icon was created when I used the ImageIcon
    constructor.
    I posted on JavaRanch and eventually realized that the image file needed to be with the
    .class files, so I moved the Images folder under bin and getResource() works fine and I'm
    happy.
    However, I have three questions for you.
    One poster on JavaRanch told me that it's better to use getResource() rather than the
    ImageIcon constructor for distributing an app (I'm not distributing anything but want
    to do it all correctly).
    Do you agree with that or can I safe keep using the ImageIcon constructor?
    Another poster told me he doesn't think it's safe to leave the image file in bin because
    it might be lost during the build in eclipse and that there is a way to have eclipse copy
    the files to bin during the build which should mean that I can leave the images folder at
    the level of bin and src.
    Do you agree with that?
    If yes, how do I get eclipse to copy the file during the build?
    P.S.
    Before I posted on JavaRanch, I put the Images folder at every level of the project's
    directory as shown in eclipse (which is why I missed the bin folder until JavaRanch
    whacked me upside the head) and getResource() still didn't work.

    The contents of the Java Source folder are compiled if they're source files, copied otherwise (assuming no filter's been put in place to prevent copying), so your images belong under a source folder.

  • Unusual use of interface defining static factory class with getInstance

    This question is prompted by a recent New to Java forum question ask about the differences between Interfaces and Abstract classes. Of course one of the standard things mentioned is that interfaces cannot actually implement a method.
    One of my past clients, one of the 500 group, uses interfaces as class factories. The interface defines a pubic static class with a public static method, getInstance, that is called to generate instances of a class that implements the interface.
    This architecture was very object-oriented, made good use of polymorphism and worked very well. But I haven't seen this architecture used anywhere else and it seemed a little convoluted.
    Here is a 'pseudo' version of the basic interface template and use
    -- interface that defines public static factory class and getInstance method
    public interface abc {
        public static class FactoryClass
            public static abc getInstance ()
                return (abc) FactoryGenerator(new abcImpl(), abc.class);
    -- call of interface factory to create an instance
    abc myABC = abc.Factory.getInstance();1. Each main functional area ('abc' in the above) has its own interface factory
    2. Each main functional area has its own implementation class for that interface
    3. There is one generator (FactoryGenerator) that uses the interface class ('abc.class') to determine which implementation class to instantiate and return. The generator class can be configured at startup to control the actual class to return for any given interface.
    I should mention that the people that designed this entire architecture were not novices. They wrote some very sophisticated multi-threaded code that rarely had problems, was high performance and was easy to extend to add new functionality (interfaces and implementing classes) - pretty much plug-n-play with few, if any, side-effects that affected existing modules.
    Is this a best-practices method of designing factory classes and methods? Please provide any comments about the use of an architecture like this.

    Thanks for the feedback.
    >
    I don't see how 'the generator class can be configured at startup to control the actual class to return for any given interface' can possibly be true given this pseudo-code.
    >
    I can see why that isn't clear just from what is posted.
    The way it was explained to me at the time is that the interface uses standard naming conventions and acts like a template to make it easy to clone for new modules: just change 'abc' to 'def' in three places and write a new 'defImpl' class that extends the interface and the new interface and class can just 'plug in' to the framework.
    The new 'defImpl' class established the baseline functionality that must be supported. This line
    return (abc) FactoryGenerator(new abcImpl(), abc.class);uses the initial version of the new class that was defined, 'abcImpl()', when calling the FactoryGenerator and it acted as a 'minimum version supported'. The generator class could use configuration information, if provided, to provide a newer class version that would extend this default class. Their reasoning was that this allowed the framework to use multiple versions of the class as needed when bugs got fixed or new functionality was introduced.
    So the initial objects would be an interface 'abc' and a class 'abcImpl'. Then the next version (bug fixes or enhancements) would be introduced by creating a new class, perhaps 'abcImpl_version2'. A configuration parameter could be passed giving 'abcImpl' as the base class to expect in the FactoryGenerator call and the generator would actually create an instance of 'abcImpl_version2' or any other class that extended 'abcImpl'.
    It certainly go the job done. You could use multiple versions of the class for different environments as you worked new functionality from DEV, TEST, QA and PRODUCTION environments without changing the basic framework.
    I've never seen any Java 'pattern' that looks like that or any pattern where an interface contained a class. It seemed really convoluted to me and seems like the 'versioning' aspect of it could have been accomplished in a more straightforward manner.
    Thanks for the feedback. If you wouldn't mind expanding a bit on one comment you made then I will mark this ANSWERED and put it to rest.
    >
    I don't mind interfaces containing classes per se when necessary
    >
    I have never seen this except at this one site. Would you relate any info about where you have seen or used this or when it might be necessary?

Maybe you are looking for

  • How to control security issues in a cluster?

    hi all: In our project we will take control of the security in front controller and we will cache the user profile . so even my app run in a cluster i want there 's just one palce to control security . but how? regards daniel

  • Can't get thumb drive(s) to work

    I have a fairly new XP SP2 install using Leopard bootcamp. In Windoze when I plug in any of my thumb drives it shows it found new hardware and tries to install the drivers, but that fails. I used the windows update mode. Any suggestions.

  • DbDataSources and Form modes

    Hi, I have a little problem, i was reading in the forum, but nobody has the same problem, so, i have a form, with 2 dbdatasources, one to OITM, and the other to OITW, in the form load i use the query method over the oitm dbdatasource and oitw dbdatas

  • I want to setup a Disaster Recovery Server for Sharepoint Server 2010

    There are four production server running sharepoint server 2010 and one SQL server for ContentDB management.

  • Discoverer Desktop v 4.1

    Anyone know where I can download Discoverer Desktop v4.1.48. Thanks..