Hashtable problems?

I just discovered hashtables :D mmm.. i find hashname.put(object, object); to be too much.. so i wrote a adhoc method for walking through two arrays and putting them into hastables :D though, i had some errors:
public Hashtable makeHash(int cap, String allString[], int allInt[])
     Hashtable hash = new Hashtable(cap);
     int i = 0;
     while(i < allString.length && i < allInt.length)
          hash.put(allString, new Integer(allInt[i]));
          i++;
     return hash;
then i ran this method:
String days[]=
     "Sun",
     "Mon",
     "Tue",
     "Wed",
     "Thu",
     "Fri",
     "Sat"
offset[] = {0, 1, 2, 3, 4, 5, 6};
makeHash(7, days[], offset[]);in eclipse, there is a red mark under the comma right after days[] in the makeHash parameter... when i mouse over it, it gave me an "Syntax error on token ",","." expected".. anyone know what i'm doing wrong?

int[] offset = {0, 1, 2, 3, 4, 5, 6} ; is valid, and, I think int offset[] = {0, 1, 2, 3, 4, 5, 6}; However, I don't think offset[] = <whatever> is valid anywhere except as part of the delaration. After declaring int[] offest or int offset[], you just use offest without the [] to refer to the array.

Similar Messages

  • Hashtable problem - java.io.NotSerializableException

    I'm having trouble writing a hashtable out to a file. I know that the writeObject() method in ObjectOutputStream requires whatever it writes to be serializable, so I made the PlayerScore class implement serializable.. Now it gives "Not serializable Exeption: java.io.NotSerializableException: PluginMain" where PluginMain is the class that contains the hashtable. If I have it Implement Serializable I get the same error with what I would guess is a super class of mine named BotCore.
    All the source is here: www.witcheshovel.com/WartsStuff/PluginMain.java
    Here are what I believe to be the offending portions of the code:
         private Hashtable<String, PlayerScore> scoreTable;
         private void saveScores() {
              try {
                   out.showMessage("Hash a a string: " + scoreTable.toString());
                   String scoreFile = getSetting("8. Score File");     
                   FileOutputStream fileOut = new FileOutputStream (scoreFile);
                   ObjectOutputStream objectOut = new ObjectOutputStream(fileOut);
                   Object scores = (Object)scoreTable;
                   //objectOut.writeObject(scores);
                   objectOut.writeObject(scoreTable);
                   objectOut.close();
                   fileOut.close();
              catch (NotSerializableException a) {out.showMessage("Not serializable Exeption: " + a);}
              catch (Exception e) {out.showMessage("Failed to save file with error:" + e);}
         public class PlayerScore implements Serializable {     //Class for keeping player scores
              String playerName;
              int longestStreak=0;
              int totalCorrect=0;
              public PlayerScore() {}
              public PlayerScore(String name) {
                   playerName = name;
              public void setTotalCorrect(int newCorrect) {
                   totalCorrect = newCorrect;
              public void incTotalCorrect() {
                   totalCorrect++;
              public void setLongestStreak(int streak) {
                   longestStreak=streak;
              public void incLongestStreak() {
                   longestStreak++;
              public String getName() {
                   return playerName;
              public int getStreak() {
                   return longestStreak;
              public int getTotalCorrect() {
                   return totalCorrect;
         }

    Does it look like this:
    class PluginMain
      class PlayerScore implements Serializable
    }If PlayerScore (or anything else you try to serialize) is an inner class it has a hidden reference to its containing class (i.e. PluginMain.this), so serializing it will try to serialize the containing class. You can make the nested class static, or place it outside the scope of the containing class. If it still needs a reference to the containing class put it in explicitly and make it transient, but you will have a problem at the receiving end.

  • Hashtables problem

    I am trying to invoke retreive(), add() delete() methods from a chaining hashtable class, The problem is I am not sure how to do it as I also have an ObjectMethods class which contains all the add, retrieve etc methods in it. It seems I can add, retrieve and delete directly from and to my LinkedList [ObjectMethods], but when I try using the ChainingHashtable methods I get a cannot resolve symbol error.
    here is some of my code.
    Manageable [] data = new ObjectMethods();//this works fine, I have a problem when I try doing Manageable[] data = new ChainingHashtable();
    //relevant switch statement
    case 2:
                   System.out.println("Enter a surname to search for: ");
                   surname = stdin.readLine();
                   AddressRecords rec = (AddressRecords)data.retrieve(surname);
                   if(rec!=null)
                        rec.display();
                   else
                   //print out that the data could not be found
                   System.out.println("ADDRESS RECORD COULD NOT BE FOUND...PLEASE TRY AGAIN");     
    //here is the code for the hashtable key
    class ChainingHashtable
    //create a datastructure and set size to 5
    public final int TABLESIZE = 5;
    Manageable [] table = new Manageable [TABLESIZE];
    //constructor: initialise the table
    ChainingHashtable()
         //build a blank linkedList for each address element
         for(int i = 0; i < table.length; i++)
              table[i] = new ObjectMethods();
    //calculate a hashcode for a given string
    public int code (String key)
         //use the hascode to get a number and
         //cut the number down to fit the size of the table
         return(Math.abs(key.hashCode()) % TABLESIZE);
    //create a retrive method
    public Object retrieve(String key)
    //calculate hashcode
    int code = this.code(key.toString());
    //retrieve the data at the list at that element
    return table.retrieve(key);

    import java.io.*;
    class AddressBook
    public static void main(String[] args) throwsIOException
    BufferedReader stdin = new BufferedReader(new InputStreamReader)
    (System.in);
    Mangeable data = new ChainingHashtable();
    String surname;
    String ......
    do
    System.out.println("Address Book");
    System.out.pritnln();
    System.out.println("1. Store a record");
    System.out.println("2. Retrieve a record");
    System.out.println("3. Delete a record");
    System.out.println("4. print a data summary");
    System.out.println("5. Quit")
    menu_option = Integer.parseInt(stdin.readLine());
    switch(menu_option)
    case 3:
    System.out.println("Enter a surname to search for and delete: ");
    surname = stdin.readLine();
    AddressRecords rec = (AddressRecords)data.retrieve(surname);
    if(rec!=null);
    rec.display();
    else
    System.out.println("AddressRecords could not be found");
    break;
    Interface Manageable
    public int size()
    public boolean add(Object data);
    public Object retrieve(String target);
    public boolean delete(string target);
    public Object[] dataDump();
    class ChainingHashtable
    public final int TABLESIZE = 5;
    Manageable[] table = new manageable[TABLESIZE];
    //constructor
    ChainingHastable()
    for(int i = 0; i < table.length;i++)
    table[i] = new AddressRecords();
    public Object retrieve(String Key)
    int hashcode = this.code(key);
    return table.retrieve(key);
    class ObjectMethods implements Manageable
    public Object retreive (String target)
    ObjectNode current = head;
    while(current!= null)
    if(current.getData().toString().equals(target))
    return current.getData();
    current = current.getData();
    return null;
    This is structure using the retreive methods as an example. i havent included the accessors and mutators as this would a little long.

  • Trying to solve the hashtable problem;

    this is a test of a part of my programming, trying to solve the hashtable
    i took out the erronous part and change some of it.i'm trying to print out a table of data with 4 column
    import java.util.*;
    public class test {
         // creating a global hashtable name "b" its
         //static just for the convieniet of it
    static Hashtable b = new Hashtable();
    public static void addItem(String keyid, String t, double p, int q){
    // array size of 4 for my value in hashtable "b"
    String [] array = new String [4];
    // puting all my variables into string array
    //including my keyid as the first in array[0]      
         array[0]=keyid;
         array[1]=t;
         array[2]= String.valueOf(p);//casting of double type to string
         array[3]= String.valueOf(q);//casting of int type to string
         b.put(id,array);//setting key = id and value = my array[]
    public static void main (String args[]) throws Exception {
         String numb = "009", piss="theone";
         double cost = 19.50;
         int a = 1;
         String [] testItem;
         addItem(numb,piss,cost,a); //call of method additem;
         Enumeration e = b.keys();
    // Get all values
    while ( e.hasMoreElements())
    {            tempItem = (String [])e.nextElement(); **// error msg here**
         System.out.println("array element 1"+tempItem[1]);
         System.out.println("array element 2"+tempItem[2]);
         System.out.println("array element 3"+tempItem[3]);
    this is my error msg "ClassCastException: java.lang.String cannot be cast to [Ljava.lang.String;"
    1 =====>cannot find symbol
    symbol  : variable id
    location: class test
            b.put(id,array);//setting key = id and value = my array[]
    2 ===>cannot find symbol
    symbol : variable tempItem
    location: class test
    tempItem = (String [])e.nextElement();
    3 ====>cannot find symbol
    symbol : variable tempItem
    location: class test
    System.out.println("array element 1"+tempItem[1]);
    is there anyway to solve this or anyone can provide me with an alternative way of printing a table with 4 col?

    you should learn to post your code inside code tags
    mangotree wrote:
    1 =====>cannot find symbol
    symbol : variable id
    location: class test
    b.put(id,array);//setting key = id and value = my array[]there is nothing called "id"
    mangotree wrote:
    2 ===>cannot find symbol
    symbol : variable tempItem
    location: class test
    tempItem = (String [])e.nextElement();
    3 ====>cannot find symbol
    symbol : variable tempItem
    location: class test
    System.out.println("array element 1"+tempItem[1]);there is nothing called "tempItem"
    mangotree wrote:
    this is my error msg "ClassCastException: java.lang.String cannot be cast to [Ljava.lang.String;"
    here you are iterating through the keys of the hash table ("b.keys()"), and your key is a String, not a String[; perhaps you want the value instead?

  • Am i missing something here? Hashtable problem

    this executes, but doen't remove the value for some odd reason, am i just not seeing something? this is really annoying me
                if (this.planListeners.contains(listener)) {
                    planListeners.remove(listener);
                    logger.finer("Removed PlanListener");
                }

    javadoc
    >
    remove
    public V remove(Object key)
    Removes the key (and its corresponding value) from this hashtable. This method does nothing if the key is not in the hashtable.
    Specified by:
    remove in interface Map<K,V>
    Specified by:
    remove in class Dictionary<K,V>
    Parameters:
    key - the key that needs to be removed.
    Returns:
    the value to which the key had been mapped in this hashtable, or null if the key did not have a mapping.
    Throws:
    NullPointerException - if the key is null.
    at least browse it next time...

  • Simple Hashtable problem - Iteration :-)

    I want to achieve the same effect as this code below, but with a hashtable. By that I mean I would like to itterate through a hashtable, but I'm not quite sure how to do it.
    ArrayList rectangles = new ArrayList();
    for (Rectangle rec : rectangles){
    }Thanks,
    Nate

    I read the API which you should too, and i came up with this big bundle of mess, lol enjoy
    private void doSomething(){
      int[] nums = {1, 2, 3};
      Object[] obs = {new Object(), new Object(), new Object()};
      Hashtable data = new Hashtable();
      for(int i=0; i<nums.length; i++){
        data.put(nums, obs[i]);
    Set k = data.keySet();
    Iterator iter = k.iterator();
    while(iter.hasNext()){
    int key = (Integer)iter.next();
    Object o = data.get(key);
    System.out.println(key + " " + o.toString());

  • Problem with reading locale from moduleImpl

    I extracted the locale bundle data from module by getViewObjects and I stored it into hashtable,
    problem is that i allways get data from default locale and not from users locale settings.
    These code is running on java servlet.
    code:
    NameModuleImpl NameModuleTmp = (NameModuleImpl)Configuration.createRootApplicationModule(propertie1,propertie2);
    for(ViewObject vo:NameModuleTmp.getViewObjects()) {
    int c=vo.getProperties().size();
    Hashtable ht=vo.getProperties();
    Greetings

    hi Rok Kogovšek
    Maybe some information in this forum thread could be relevant:
    "ADF BC : using UI Locale to translate data (Steve M. example 95)"
    ADF BC : using UI Locale to translate data (Steve M. example 95)
    regards
    Jan Vervecken

  • Searching in Hashtable

    Hi,
    I have a problem to search in a Hashtable.
    Someone can help me?
    Thanks

    Probably; many Hashtable problems have been solved in this forum already. If there's not a solution to your problem in an old thread already, I believe you should go ahead and describe it as well and fully as you can, and also what you did to solve it already, so nobody needs to post a suggestion you already tried.
    Message was edited by: OleVV
    OleVV

  • Problem with doubleValue() method and hashtable

    Hi,
    I made a type double variable named tempNumber.
    and I used this to put that number in a hashtable
    CODE 1 : hash.put(key, new Double(tempNumber));
    Then I wrote this code to retrieve it.
    CODE 2: (hash.get(st.sval)).doubleValue();
    Note: I am using streamtokenizer to get the nexttoken, so st.sval is a string representation of the token.
    Now my problem is when I compile CODE 2, I get an error message saying that "method doubleValue() not found in java.lang.Object". Whats going on here??
    I am using java 1.1 by the way.
    Thanks in advance...

    Hash table stored and returns objects. You have to typecast the return value of get() method to Double and then call doubleValue() on it.
    Its something as follows
    ((Double)hash.get(key)).doubleValue()

  • Hashtable containsKey() problem when String key is read from a file - HELP

    I'll try to be brief:
    I open a .txt file of Unicode encoding (not ANSI) in order to fetch some info.
    After I manipulate each line with splits etc I use a String as a key to a Hashtable.
    The problem is that later inside my code, I try to check wether this key (and hence its corresponded value) exists and I get a false value from the containsKey() method.
    and here's the code (I have embedded some comments //-type that address to this thread):
    FileInputStream fis = new FileInputStream(initFilename);
    InputStreamReader isr = new InputStreamReader(fis, "UTF-16");
    BufferedReader br = new BufferedReader(isr);
    lineText = loadSubiPhraseFilter(br);
    //In the loadSubiPhraseFilter method
    //parsing an input like this:
    //&#948;&#972;&#958;&#945; &#964;&#974; &#920;&#949;&#974;,1:1,2:2
    //Yeah, I know, its all greek to you ;)
    //Thus we first split the line with ','
    //we split the first token with ' ' and each one of the N words,
    //serves as an index in a N-dimension hashtable
    //This is achieved implicitly by adding another hashtable as a value to a String key etc...
    //When all words are added, the hashtable which contains the last word is used
    //to put another hashtable whose only key is the String "Index"
    //which points to the rest of the data. The thing is, I never get that far...
    //I dont get to even get a positive containsKey() when giving an inserted key at a later time
    //here's the loading procedure
    while((lineText = br.readLine()) != null && (lineText.charAt(0) != '#'))
         String [] info = lineText.split("[,]");
         /*Load subi indeces in a vector*/
         Integer [][] subiIndex = new Integer [info.length-1][2];// = new Vector<Integer>();
         for(int i = 1; i < info.length; i += 1)
              //load subiIndex here...
         /*Then fetch phrase to be modified and load its 'n' words in an n-dimesion hash which will utterly point to the subi indeces*/
         /*Starting from the last word, we  put the index vector*/
         String [] word = info[0].split("[ ']+");
         Hashtable<String, Object> nextWord = new Hashtable<String, Object>();
         nextWord.put("Index", subiIndex);
         /*Then we create a chain of hash dimensions corresponding to phrase words*/
         for(int i = word.length-1; i >= 0; i -=1)
              Hashtable<String, Object> prevWord = new Hashtable<String, Object>();
              //Yeah, I even tried the .trim() method...
              prevWord.put(word.trim(), nextWord);
              nextWord = prevWord;
              System.out.print(word[i] + "<-");
         /*We update the hash head and also add the first word with its first letter capitalized as key pointing to the same next key in hash dimension chain*/
         subiPhraseFilter = nextWord;
         subiPhraseFilter.put((capitalMap.get(word[0].charAt(0))+word[0].substring(1)).trim(), subiPhraseFilter.get(word[0]));
         //The following debbuging print outs work just fine. Its only just later when I cant get a containsKey()...
         System.out.println("|| "+subiPhraseFilter);
         System.out.println("subiPhraseFilter.containsKey("+word[0]+"): "+subiPhraseFilter.containsKey(word[0]));
    //Then the following code is executed
    Integer [][] subiPhraseIndeces(String word1, String word2, String word3)
         String [] tmp = {word1, word2, word3};
         Hashtable<String, Object> dimension = subiPhraseFilter;
         //The following debbuging print out does NOT return true
         //even when I explicitly give a String key which I know it is inserted
         System.out.println("subiPhraseFilter.containsKey(" + tmp[0] + "): " + subiPhraseFilter.containsKey("&#949;&#957;&#955;&#972;&#947;&#969;".trim()));
         for(int i = 0; (i < tmp.length) && (tmp[i] != null) && dimension.containsKey(tmp[i]); i += 1)
              //This is NEVER executed...
              System.out.println(i + ": dimension.containsKey(" + tmp[i].trim() + ")");
              dimension = (Hashtable<String, Object>)dimension.get(tmp[i].trim());
              return (Integer [][])dimension.get("Index");
    Whats most irritating is that this also happens arbitrarily in another place of my code where I load again info by using each line as a key to another Hashtable and, the containsKey() method returns true to all but one (!) line-words, even if I change its position in the file. I won't put the latter code here because its just very simple. (in case I wasnt clear I read a section of a file that looks like
    wordA
    wordB
    wordC
    wordN
    each wordX is put as a key to a Boolean value and yet, containsKey(wordA) returns false even if i change the input file to
    wordB
    wordA
    wordC
    wordN
    isn't that just peculiar?
    A significant note in this problem is that I do not read english characters, rather than greek (hence the unicode filetype) which I put as keys to the hashtable; later I try to get corresponded values by fetching text (which I also manipulate) from a JTextfield, as key, and I'm afraid that maybe something is happening there.
    However the code sample I added above didnt work even when I added an english word in the file and explicitly asked wether it is contained as a key...
    Maybe I am doing something I really can't see right now...
    Help would be appreciated                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    BalusC: "I would also not be surprised if that file is after all actually just UTF-8"
    No, it's not cause I explictly saved the .txt file as Unicode in wordpad and NOT as UTF-8. By the way notepad has ANSI as its default save-type.
    However I converted my input files to UTF-8 and read them using the "UTF-8" String flag in the constructor of the reader I was using. All the same.
    EDIT: Not to metion, the UTF-8 file needed an empty line at the beggining or my parsing would skip the first line, messing everything up!
    Just for the sake of it I will show the output of my program (redirected to a file cause cmd.exe does not support greek letters, or I didnt find a way to make it so):
    (This is the output when I load from the UTF-8 file the word "&#949;&#957;&#955;&#972;&#947;&#969;" in my has as a key (pointing to a Boolean i think - it doesnt really matter). What I print is the key of each dimension of the hash -here there's only one dimension- and then I print the hash reference, i.e like a toString() representation. The result shows that the Hashtable contains at key "&#949;&#957;&#955;&#972;&#947;&#969;" a value which is another Hashtable which contains the key "Index" pointing to something you shouldnt care. The hash head also contains the key "&#917;&#957;&#955;&#972;&#947;&#969;", which is actually the same as before only to have its first letter capitalized, which in turn points to a hash with one key etc...)
    &#949;&#957;&#955;&#972;&#947;&#969;<-|| {&#949;&#957;&#955;&#972;&#947;&#969;={Index=[[Ljava.lang.Integer;@360be0}, &#917;&#957;&#955;&#972;&#947;&#969;={Index=[[Ljava.lang.Integer;@360be0}}
    subiPhraseFilter.containsKey(&#949;&#957;&#955;&#972;&#947;&#969;): true
    (And later on I get a string from a JTextField I tokenize it and here's what I get when I reach the same word:)
    (Don't mind "Checking: ..." its 'cause I check a window of three words in order to reach up to a 3-dimension hash key. Yet I dont even get the first key!)
    Current token: '&#949;&#957;&#955;&#972;&#947;&#969;'
    Checking: &#949;&#957;&#955;&#972;&#947;&#969;, null, null
    subiPhraseFilter.containsKey(&#949;&#957;&#955;&#972;&#947;&#969;): false
    Now isn't that making one crazy?
    Any other ideas?
    Thnak you in advance!
    P.S. In case that I haven't done something really stupid which is ommitted here and yet can't be tracked, I think the problem must be somewhere between the encoding of JTextField and the encoding I read...
    P.S.2 Excuse me for saying hash instead of Hashtable sometimes in the above text
    Edited by: M.M. on Sep 2, 2009 3:22 AM
    Edited by: M.M. on Sep 2, 2009 3:23 AM

  • Jax-ws 2.1 - problems returning hashtable and hashmap

    Hi,
    We're developing a set of applications that communicate via web services.
    The company decided that to do this we should use jax-ws 2.1.
    Everything is going ok, its really easy to use, except for a web method that returns a java.util.Hashtable.
    In the endpoint there's no problem, it compiles and deploys to a tomcat 5.5 without a problem.
    The client can access the wsdl via url, download it and create the necessary files (we use netbeans 5.5 for this).
    We can invoke the method getConfig without a problem, but the object returned only has the java.lang.Object 's methods, not the java.util.Hastable 's .
    Endpoint:
    package xxx.cdc_pm_i;
    import java.util.Hashtable;
    import javax.jws.WebMethod;
    import javax.jws.WebParam;
    import javax.jws.WebService;
    import javax.xml.bind.annotation.*;
    @WebService()
    public class cdc_pm_i{
    @WebMethod
    public Hashtable getConfig() {
    Hashtable<String,String> config = new Hashtable<String,String>();
         config.put("1","1");
         config.put("2","2");
    return config;
    Client:
    try { // Call Web Service Operation
    xxx.CdcPmIService service = new xxx.cdc_pm_i.CdcPmIService();
    xxx.cdc_pm_i.CdcPmI port = service.getCdcPmIPort();
    // TODO process result here
    xxx.cdc_pm_i.Hashtable result = port.getConfig();
    } catch (Exception ex) {
         ex.printStackTrace();
    I'm fairly unexperienced in Web Services and i have no idea why this works for any kind of return object (as long as its serializable) and has this problem with hashtables and hashmaps.
    Any idea on how to solve this?
    Thanks in advance,
    Rui

    Didn't find the solution for this, but any object that contains an Object in its methods / attributes had the same problems, so i just built my own table that only supports Strings and the problem was solved.
    If anyone knows why i had this problem and wants to share a solution, please do so.

  • Problem with Hashtable put

    Hi
    Can someone please tell what wrong with my code, I'm getting NullPointerException while I was compiling
    class X509Cert{
    private X509Certificate cert;
    //subject distinguished name
    String sbcn,sbou,sbo,sbl,sbc,sbe;
    public void X059Cert()
      this.sbcn="";
      this.sbou="";
      this.sbo="";
      this.sbl="";
      this.sbc="";
      this.sbe="";
    public void setSubjectDN(String CN, String OU, String O, String L, String C, String E)
      this.sbcn=CN;
      this.sbou=OU;
      this.sbo=O;
      this.sbl=L;
      this.sbc=C;
      this.sbe=E;
    public void genCert(PrivateKey prikey, PublicKey pubkey)
      //subject distinguished name
      Hashtable subjectdn=new Hashtable();
      subjectdn.put(X509Principal.CN, this.sbcn);  <--------- what problem with this 
      subjectdn.put(X509Principal.OU, this.sbou);
      subjectdn.put(X509Principal.O, this.sbo);
      subjectdn.put(X509Principal.L, this.sbl);
      subjectdn.put(X509Principal.C, this.sbc);
      subjectdn.put(X509Principal.E, this.sbe);I really need your help, Thank

    Hi UlrikaJ
    Thank for your help
    it wil not have that problem, if I change it to :
    attrs.put(X509Principal.C, "AU");
    attrs.put(X509Principal.O, "The Legion of the Bouncy Castle");
    attrs.put(X509Principal.L, "Melbourne");
    attrs.put(X509Principal.ST, "Victoria");
    attrs.put(X509Principal.E, "[email protected]");I thank this is somthing about pass by reference or value problem, isn't it .

  • Strange Problem with a Vector wraped inside a Hashtable

    Hi all ,
    I'm having a strange problem with a Vector wraped within a Hashtable inherited Class.
    My goal is to keep the order of the elements of the Hashtable so what I did was to extend Hashtable and wrap a Vector Inside of it.
    Here is what it looks like :
    package somepackage.util;
    import java.util.Enumeration;
    import java.util.Hashtable;
    import java.util.Vector;
    public class OrderedHashTable extends Hashtable {
        private Vector index;
        /** Creates a new instance of OrderedHashTable */
        public OrderedHashTable() {      
            this.index = new Vector();
    //adds a key pair value to the HashTable and adds the key at the end of the index Vector
       public synchronized Object put(Object key,Object value){      
           index.addElement(key);
           Object obj = super.put(key,value);
           System.out.println("inside OrderedHashTable Put method index size = " + index.size());
           return obj;    
    public synchronized Object remove(Object key){
           int indx = index.indexOf(key);
           index.removeElementAt(indx);
           Object obj = super.remove(key);
           return obj;
    public synchronized Enumeration getOrderedEnumeration(){
           return index.elements();
    public synchronized Object getByIndex(int indexValue){
           Object obj1 = index.elementAt(indexValue);
           Object obj2 = super.get(obj1);      
           return obj2;
       public synchronized int indexOf(Object key){
        return index.indexOf(key);
        public synchronized int getIndexSize() {
            return index.size();
        }Everything seemed to work fine util I tried to add objects using a "for" loop such as this one :
    private synchronized void testOrderedHashTable(){
            OrderedHashTable test = new OrderedHashTable();
            for (int i = 1 ; i<15; i++){
                 System.out.println("adding Object No " + i);
                 String s = new String("string number = "+i);
                 test.put(new Integer(i),s);
                 System.out.println("-----------------------------------");
            //try to list the objects
            Enumeration e = test.getOrderedEnumeration();
            while (e.hasMoreElements()){
                Integer intObj = (Integer) e.nextElement();
                System.out.println("nextObject Number = "+ intObj);
        }Here is the console output :
    Generic/JSR179: adding Object No 1
    Generic/JSR179: inside OrderedHashTable Put method index size = 1
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 2
    Generic/JSR179: inside OrderedHashTable Put method index size = 2
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 3
    Generic/JSR179: inside OrderedHashTable Put method index size = 3
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 4
    Generic/JSR179: inside OrderedHashTable Put method index size = 4
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 5
    Generic/JSR179: inside OrderedHashTable Put method index size = 5
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 6
    Generic/JSR179: inside OrderedHashTable Put method index size = 6
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 7
    Generic/JSR179: inside OrderedHashTable Put method index size = 7
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 8
    Generic/JSR179: inside OrderedHashTable Put method index size = 8
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 9
    Generic/JSR179: inside OrderedHashTable Put method index size = 10
    Generic/JSR179: inside OrderedHashTable Put method index size = 10
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 10
    Generic/JSR179: inside OrderedHashTable Put method index size = 11
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 11
    Generic/JSR179: inside OrderedHashTable Put method index size = 12
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 12
    Generic/JSR179: inside OrderedHashTable Put method index size = 13
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 13
    Generic/JSR179: inside OrderedHashTable Put method index size = 14
    Generic/JSR179: -----------------------------------
    Generic/JSR179: adding Object No 14
    Generic/JSR179: inside OrderedHashTable Put method index size = 15
    Generic/JSR179: -----------------------------------
    Generic/JSR179: nextObject Number = 1
    Generic/JSR179: nextObject Number = 2
    Generic/JSR179: nextObject Number = 3
    Generic/JSR179: nextObject Number = 4
    Generic/JSR179: nextObject Number = 5
    Generic/JSR179: nextObject Number = 6
    Generic/JSR179: nextObject Number = 7
    Generic/JSR179: nextObject Number = 8
    Generic/JSR179: nextObject Number = 9
    Generic/JSR179: nextObject Number = 9
    Generic/JSR179: nextObject Number = 10
    Generic/JSR179: nextObject Number = 11
    Generic/JSR179: nextObject Number = 12
    Generic/JSR179: nextObject Number = 13
    Generic/JSR179: nextObject Number = 14
    You can notice that the output seems correct until the insertion of object 9.
    At this point the vector size should be 9 and the output says it is 10 elements long ...
    In the final check you can notice the 9 was inserted twice ...
    I think the problem has something to do with the automatic resizing of the vector but I'm not really sure. Mybe the resizing is done in a separate thread and the new insertion occurs before the vector is resized ... this is my best guess ...
    I also tested this in a pure J2SE evironment and I don't have the same strange behavior
    Can anybody tell me what I am doing wrong or how I could avoid this problem ?
    Thanks a lot !
    Cheers Alex

    Am i doing anything wrong?Uhm, yes. Read the API doc for addElement() and for addAll()

  • Performance problem - XML and Hashtable

    Hello!
    I have a strange (or not strange, we don't know) performance problem. The situation is simple: our application runs on Oracle IAS, and gets XML messages from an MQ, and we have to process them.
    Sample message:
    <RequestDeal RequestId="RequestDeal-20090209200010-998493885" CurrentFragment="0" EndFragment="51" Expires="2009-03-7T08:00:10">
         <Deal>
              <Id>385011</Id>
              <ModifyDate>2009-02-09</ModifyDate>
              <PastDuesOnly>false</PastDuesOnly>
         </Deal>
         <Deal>
              <Id>385015</Id>
              <ModifyDate>2009-02-09</ModifyDate>
              <PastDuesOnly>false</PastDuesOnly>
         </Deal>
    </RequestDeal>(there's an average of 50000-80000 deals in the whole message)
    After the application receives the whole message, we'd like to parse it, and put the values into a hashtable for further processing:
        Hashtable ht = new Hashtable();
        Node eDeals = getElementNode(docReq, "/RequestDeal");
        Node eDeal = (Element)(eDeals.getFirstChild());
        long start = System.currentTimeMillis();
        while (eDeal != null) {
          String id = getElementText((Element)eDeal, "Id");
          Date modifyDate = getElementDateValue((Element)eDeal, "ModifyDate");
          boolean szukitett = getElementBool((Element)eDeal, "PastDuesOnly", false);
          ht.put(id, new UgyletStatusz(id, modifyDate, szukitett));
          eDeal = eDeal.getNextSibling();
        logger.info("Request adatok betöltve.");
        long end = System.currentTimeMillis();
        logger.info("Hosszu muvelet ideje: " + (end - start) + "ms");The problem is the while statement. On my PC it runs for 15-25 seconds, depends on the number of the deals; but on our customer's server, it runs for 2-5 hours with very high CPU load. The application uses oracle xml parser.
    On my PC there are Websphere MQ 5.3 and Oracle 10ias with 1.5 JVM.
    On our customers's server there are Websphere MQ 5.3 and Oracle 9ias with 1.4 HotSpot JVM.
    Do you have any idea, what can be the cause of the problem?

    gyulaur wrote:
    Hello!
    The problem is the while statement. On my PC it runs for 15-25 seconds, depends on the number of the deals; but on our customer's server, it runs for 2-5 hours with very high CPU load. The application uses oracle xml parser.
    On my PC there are Websphere MQ 5.3 and Oracle 10ias with 1.5 JVM.
    On our customers's server there are Websphere MQ 5.3 and Oracle 9ias with 1.4 HotSpot JVM.
    Do you have any idea, what can be the cause of the problem?All sorts of things are possible.
    - MQ is configured differently. For instance transactional versus non-transactional.
    - The customer uses a network (multiple computers) and you use a box (singlur) and something is using a lot of bandwidth on the network. Could be your process, one of the dependent processes or something else that has nothing to do with your system
    - The processing computer is loaded with something else or something is artificially limiting the processing time of your application (there is a app that allows one to limit another app to one CPU.)
    - At least one version of 1.4 had a xml bug that consumed massive amounts of memory when processing large xml. Sound familar? If the physical memory is not up to it then it will be thrashing the hard drive as it swaps virtual in and out.
    - Of course virtual memory causing swaps would impact it regardless of the cause.
    - The database is loaded.
    You can of course at least get the same version of java that they are using. Actually that would seem like a rather good idea to me regardless.

  • Hashtable and DB results problem

    Hi guys i have a problem, i am retrieving two sets of data from a db based on a query and then putting these values into a hashtable to use later the problem is that once i put it into the hashtable i loose the order the were returned by i have two fields
    code and number code for example
    Code number code
    ACCC 02
    BBCC 01
    DDCC 02
    DDCC 30
    the problem is i have it to return by code then number code asc but when outputting from the hashtable i get the following
    aacc 02
    bbCC 01
    DDCC 30 --wrong order
    DDCC 02 --- wrong order
    is there anyway i can preserve the order that is returned from the databse, i cant really use anything other than a hashtable as there are so many implications on the existing code that would have to be changed.
    0

    LinkedHashMap

Maybe you are looking for

  • How do i back up my itunes library to multiple dvd's

    I have 7.32GB of music file and from the instructions provided for copying my music folder to a dvd, it tells me the dvd is not large enough...duh.....but it doesn't give me the option to use multiple dvd's.  I tried zipping the file but that still d

  • Deletion of Open Reservation

    Sir, Please, tell me how to delet open reservation or partially open reservation.( t-code MB21) Manoj.

  • How to erase all content in MacBook Pro?

    I need to erase all data and content in my MacBook. How can I do this?

  • Leopard will not install on Macbook Pro

    I have been reading all the posts here and am very surprised at all the issues. I expect this out of Micrsoft not Apple. I have close to 6 hours into this install and here I sit typing this in Tiger. I had the failed install where it tells me that I

  • Rmi server problem

    hi Can anybody tell me how to stop the Jvm to free the Rmi server port and the remote object?