Hashtable Array

How can i initialize an Array of Hashtables with a certain type <String, Object> without warning.
Example:
private Hashtable<String, Object> items[];
items = new Hashtable[5];but the warning:
"Type safety: The expression of type Hashtable[] needs unchecked conversion to conform to Hashtable<String,Object>[]"
always appears, then i rewrote it with:
items = new Hashtable<String, Object>[5];At this time the code is wrong in java syntax.
Message was edited by:
qizhi

Java does not seem to allow generic array creation, i.e.
Hashtable<String,Object>[] items = new Hashtable<String,Object>[5];results in a compiler error. Try using a List, e.g. ArrayList instead.

Similar Messages

  • [SOLVED] - How to Rename a Win 7 Computer Using Powershell (deployment)

    For those who just want to know what I'm trying to do here's my question:
    How I can programmatically rename machines during the auditSystem/auditUser portion of Sysprep using PowerShell?
    What is the exact command and/or function should I be issuing?
    History:
    I've scoured the web for a while but unsuccessfully located what I was looking for.  I'm preparing a Windows 7 Enterprise x86 image for deployment, and I need to rename the machine to match our current PC name schema before it is joined to the domain. 
    I've managed to pull the information I needed to build the corret computer name thanks to Win32_BIOS.SerialNumber, Win32_ComputerSystem.Model and some IP<->Hashtable Array matching.  The next step is to actually rename the machine; This is
    where I'm having trouble.
    I found this code online :
    Function Rename-ComputerName ([string]$NewComputerName){
    $ComputerInfo = Get-WmiObject -Class Win32_ComputerSystem
    $ComputerInfo.rename($NewComputerName)}
    I also found
    this code online :
    function renameAndReboot([string]$computer, [string]$newname){
    $comp = gwmi win32_computersystem  -computer $computer
    $os   = gwmi win32_operatingsystem -computer $computer
    $comp.Rename($newname)
    $os.Reboot()}
    Unfortunately, neither work in PowerShell on my reference image PC running Windows 7.  (However the first one works in PowerShell on my XP Virtual PC.)
    The ReturnValue is 1326 when run on the Win 7 machine as the Administrator.  I'm not quite certain I understand what & why that fails or what exactly that code means.
    Moving on, I decided to go down the WMIC path instead:
     WMIC ComputerSystem where Name="%computername%" call Rename Name="$NewName"
    This works in CMD.exe on Windows XP and to my surprise, in CMD.exe on Windows 7 as well!  But, when run from PowerShell I get "Error: Invalid query".
    Thinking PowerShell might not like the CMD.exe %COMPUTERNAME% environment variable, I sprang for the PowerShell $env:computername environment variable instead:
     WMIC ComputerSystem where Name="$env:computername" call Rename Name="$NewName"
    That unfortunately results in an 'Unexpected switch at this level' error.
    Other suggestions I've seen online were to use netdom, but that's not part of the Win 7 install and since I've historically been able to do this through WMI calls, it should be possible to do this in Win 7, Vista, Server etc.
    I'm completely open to the idea that perhaps I'm doing something wrong.  If you have a tested solution, please share.

    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
    <settings pass="generalize">
    <component name="Microsoft-Windows-Security-SPP" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SkipRearm>1</SkipRearm>
    </component>
    </settings>
    <settings pass="specialize">
    <component name="Microsoft-Windows-Deployment" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <RunSynchronous>
    <RunSynchronousCommand wcm:action="add">
    <Order>1</Order>
    <Path>net user administrator /active:yes</Path>
    </RunSynchronousCommand>
    </RunSynchronous>
    </component>
    <component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SkipAutoActivation>true</SkipAutoActivation>
    </component>
    <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <OEMInformation>
    <Manufacturer>Company Name</Manufacturer>
    <Model>Company Owned Hardware</Model>
    <SupportHours>Mon-Fri 8 AM - 8 PM Central Time; excluding Holidays</SupportHours>
    <SupportPhone>1-888-xxx-xxxx</SupportPhone>
    <SupportURL>http://our.support.url.information</SupportURL>
    <Logo>%WINDIR%\WallPapr2.bmp</Logo>
    </OEMInformation>
    <OEMWelcomeCenter>
    <link>http://our.helpdesk.information</link>
    </OEMWelcomeCenter>
    <ComputerName></ComputerName>
    <CopyProfile>true</CopyProfile>
    <ShowWindowsLive>false</ShowWindowsLive>
    <TimeZone>Central Standard Time</TimeZone>
    <ProductKey>FJ82H-XT6CR-J8D7P-XQJJ2-GPDD4</ProductKey>
    </component>
    <component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Identification>
    <Credentials>
    <Domain>domainname</Domain>
    <Password>password</Password>
    <Username>domainadmin</Username>
    </Credentials>
    <JoinDomain>domainname</JoinDomain>
    <MachineObjectOU>OU=OU Information,DC=com</MachineObjectOU>
    </Identification>
    </component>
    </settings>
    <settings pass="oobeSystem">
    <component name="Microsoft-Windows-International-Core" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <InputLocale>en-us</InputLocale>
    <SystemLocale>en-us</SystemLocale>
    <UILanguage>en-us</UILanguage>
    <UserLocale>en-us</UserLocale>
    <UILanguageFallback>en-us</UILanguageFallback>
    </component>
    <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <AutoLogon>
    <Password>
    <Value>encrypted info</Value>
    <PlainText>false</PlainText>
    </Password>
    <Enabled>true</Enabled>
    <LogonCount>3</LogonCount>
    <Username>administrator</Username>
    </AutoLogon>
    <FirstLogonCommands>
    <SynchronousCommand wcm:action="add">
    <CommandLine>%WINDIR%\Setup\Scripts\NewPC1.cmd</CommandLine>
    <Description>Change Machine Name and Reboot</Description>
    <Order>1</Order>
    <RequiresUserInput>false</RequiresUserInput>
    </SynchronousCommand>
    <SynchronousCommand wcm:action="add">
    <CommandLine>%WINDIR%\Setup\Scripts\NewPC2.cmd</CommandLine>
    <Order>2</Order>
    <RequiresUserInput>false</RequiresUserInput>
    <Description>More Cleanup Work</Description>
    </SynchronousCommand>
    </FirstLogonCommands>
    <OEMInformation>
    <Manufacturer>Company Name</Manufacturer>
    <Model>Company Owned Hardware</Model>
    <SupportHours>M-F, 8 am - 8 pm Central excluding Holidays</SupportHours>
    <SupportPhone>1-888-xxx-xxxx</SupportPhone>
    <SupportURL>http://our.support.url.information</SupportURL>
    </OEMInformation>
    <OEMWelcomeCenter>
    <link>http://our.helpdesk.information</link>
    </OEMWelcomeCenter>
    <OOBE>
    <HideEULAPage>true</HideEULAPage>
    <NetworkLocation>Work</NetworkLocation>
    <ProtectYourPC>3</ProtectYourPC>
    </OOBE>
    <UserAccounts>
    <AdministratorPassword>
    <Value>encrypted info</Value>
    <PlainText>false</PlainText>
    </AdministratorPassword>
    <LocalAccounts>
    <LocalAccount wcm:action="add">
    <Password>
    <Value>encrypted info</Value>
    <PlainText>false</PlainText>
    </Password>
    <Description>Local Administrator</Description>
    <DisplayName>Administrator</DisplayName>
    <Group>Administrators</Group>
    <Name>Administrator</Name>
    </LocalAccount>
    </LocalAccounts>
    </UserAccounts>
    <RegisteredOrganization>Company Name</RegisteredOrganization>
    <RegisteredOwner>Licensed CompanyEmployee</RegisteredOwner>
    <TimeZone>Central standard Time</TimeZone>
    </component>
    </settings>
    <cpi:offlineImage cpi:source="wim:location/of/install.wim#Windows 7 PROFESSIONAL" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
    </unattend>
    Jnaas. My Answer file?
    I hope I didnt leave anything incriminating in that file...
    The product key is the generic one for Windows 7 to tell it to use the KMS server.

  • Game server: Map managing questions

    Hello everyone,
    I'm trying to develop some kind of RPG. I have different issues, where I need advice:
    1) Map(2D) managment on game server
    The map I want to keep in memory on server will contain objects such as: Item, NPC, Character, etc.
    Item, NPC, Character and other objects going to extend MapObject class, because I want to keep all this data in same place.
    Let's suppose that the map will have 50x50 tiles..
    I want to use Hashtable array to store elements there... So I will have something like this:
    Hashtable <String, MapObject>[][] map = new Hashtable[50][50];
    String(aka key) is going to be object_name + "_" + object_id..
    The questions are:
    - What about performance in this situation?
    - Is there any other data structure which can suite better to this situation?
    2) The other question I have is about sending map object(once in fixed period of time) and updates(for example some character walked or picked an item).
    The architecture I thought for sending data to client is:
    TCP Connection for authentication anc chat
    MultiCast Socket for synchronizing map object and sending updates
    - Is this aceptable architecture for server?
    - Is MultiCast socket good for sending updates and map object?(because there will be significant gain in term of computation on server, comparing to TCP, but what about losses of packets? what about traffic? what kind of protections(excluding timeouts) should I implement on client-side? )
    Thank you in advance.

    patriot87 wrote:
    Strange... I have also tried with 200k and same results... :D
    How comes?Well, one reason is that your test is broken. The first set of tests will always take longer, cause it's before hotspot has kicked in, etc. I moved the test to a method, precreated the objects (remember, if gc happens in one and not the other it's a huge difference), and called them repeatedly. Once I did that, there wasn't really a noticeable difference between them:
    import java.util.HashMap;
    import java.util.Hashtable;
    import java.util.Map;
    import java.util.Random;
    public class HashMapTest
       private static MapObject[] objs = new MapObject[200000];
       private static Random gen = new Random();
       public static void main(String [] agrs)
          for ( int i = 0; i < objs.length; i++ ) {
             objs[i] = new MapObject("ID" + i, "NAME"+i);
          hashMap();
          hashTable();
          hashMap();
          hashTable();
          hashMap();
          hashTable();
          hashMap();
          hashTable();
       private static void hashMap() {
          doTest(new HashMap<String, MapObject>());
       private static void hashTable() {
          doTest(new Hashtable<String, MapObject>());
       private static void doTest(Map<String, MapObject> map) {
          long start_time = System.currentTimeMillis();
          for (int i = 0; i < objs.length; i++)
             map.put(objs.id , objs[i]);
    for (int i = 0; i < objs.length; i++)
    int randomInt = gen.nextInt(objs.length);
    map.get("ID" + randomInt);
    System.out.println(map.getClass() + ": " + (System.currentTimeMillis() - start_time));
    class MapObject
    String name;
    String id;
    public MapObject (String id, String name)
    this.id = id;
    this.name = name;
    }Results of one arbitrary test:
    [pre]class java.util.HashMap: 343
    class java.util.Hashtable: 500
    class java.util.HashMap: 313
    class java.util.Hashtable: 328
    class java.util.HashMap: 453
    class java.util.Hashtable: 313
    class java.util.HashMap: 296
    class java.util.Hashtable: 454[/pre]
    Edited by: endasil on 13-Nov-2009 10:34 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Working with collections in powershell

    Hi,
    I'm struggeling with collections in Powershell in general.
    I have a variable of type SPWebCollection created and want to add
    1) a single SPWeb - Object
    2) another collection of SPWeb - Objects
    Can someone tell me please why the following doesn't work:
    [Microsoft.Sharepoint.SPWebCollection]$allWebs += Get-SPWeb $URL1
    or this
    [Microsoft.Sharepoint.SPWebCollection]$allWebs += $site.AllWebs | Where-Object {$_.Url -like $URL2}
    Finally I want to empty the $allWebs collection i.e. remove all objects. How do I do that?
    I appreciate any feedback
    Thank you

    Hi,
    According to your description, you might want to gather all the SPWeb object into a collection object in order to delete all of them finally.
    As we can see, there is no such method in
    SPWebCollection object can meet you requirement, as a workaround, we can push all the SPWeb objects into an array, then operate
    these SPWeb objects in this array would do the trick.
    Here is a link about how to create a generic collection for a list of objects:
    http://www.andreasbijl.com/powershell-create-collections-of-custom-objects/
    More information about using collection in PowerShell:
    https://www.simple-talk.com/sysadmin/powershell/powershell-one-liners--collections,-hashtables,-arrays-and-strings/
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

  • Programming data interface

    Hello,
    I am pretty new at java programming and I have to write an interface with an external system sending data to our system in some ValueObject formats. I want to create my own Object for interface purposes, but I
    don't have a clue what to use: Vector, HashTable, Array???
    The structure I would like to have is as follows:
    OBJECT: -> tableName (String)
    -> Records -> Record1 ->Field1 ->fieldName
    ->fieldValue
    ->fieldType
    ->fieldFormat
    ->Field2 ->fieldName
    ->fieldValue
    ->fieldType
    ->fieldFormat
    ->...
    ->Fieldn
    -> Record2 ->Field1...
    -> Record3
    -> ...
    -> Recordn
    So, the number of records is unknown and the number of fields is also
    unknown as this can be for different database tables.
    If anybody could help me with this I would be really greatful...
    Or if somebody already did something like this and can give me some
    example code, also very helpful!
    Or maybe if you would have a better idea than my structure to create
    an object containing data that has to be inserted in a database table
    let me know!
    Thanks a lot,
    Sven

    The following is a fairly simple way of doing something similar to what you want to do. However it assumes that you are being sent an ObjectStream (If not then the AField will have to change so that it reads the different types of data and then converts to a string)
    It also depends on the mark operation which I fear may not be suppprted for ObjectInputStreams.
    This code probably won't do what you want it to do, but I hope it should give a good starting point.
    -Philip.
    import java.util.*;
    import java.io.*;
    class AField {
        String name;
        String value;
        String type;
        String format;
        public int hashCode(){
            return name.hashCode();
        public static AField readAField(ObjectInputStream in){
            AField toReturn = new AField();
            try{
                toReturn.name = (String)in.readObject();
                toReturn.value = (String)in.readObject();
                toReturn.type = (String)in.readObject();
                toReturn.format = (String)in.readObject();
                return toReturn;
            }catch (Exception e){
                return null;
    class ARecord{
        Set fields = new HashSet();
        public static ARecord readARecord(ObjectInputStream in){
            ARecord toReturn = new ARecord();
            boolean finished = false;
            try{
                while (!finished){
                    in.mark(4096);
                    AField temp = AField.readAField(in);
                    if (toReturn.fields.contains(temp)){
                        in.reset();
                        finished = true;
                    } else
                        toReturn.fields.add(temp);
            }catch (Exception e) {}
            return toReturn;
    class Table {
        ArrayList records = new ArrayList();
        String name;
        public static Table readTable(ObjectInputStream in){
            Table toReturn = new Table();
            try{
                toReturn.name = (String)in.readObject();
                while (in.available() !=0){
                    toReturn.records.add(ARecord.readARecord(in));
            }catch (Exception e){}
            return toReturn;

  • Starting Public Worflows Within An Application

    The documentation for starting a public workflow within an application is ambiguous.
    At the following location: http://e-docs.bea.com/wlintegration/v2_0/collaborate/workflow/start.htm#1331638
    you state that a workflow instance is retrieved using the startWorkflow method.
    Unfortunately, this is a custom method that must be written and there is no suggested
    implementation.
    In terms of creating a workflow instance:
    For the WorkflowInstance class, there is only one documented constructor (although,
    there are 2 constructors). This constructor indicates that a Hashtable Array of
    Party properties is a parameter. The documentation doesn't tell us specifically
    what goes in these Hashtables, though. And as for the second constructor, we have
    no documentation and there is no mention in the API, but I do know that it takes
    3 Strings as its parameters.
    How do I start a public workflow within an application?
    Thanks in advance,
    Mark

    Replace:
    WorkflowInstance wi = startWorkflow();
    with:
    Hashtable[] array = new Hashtable[2];
    Hashtable party1 = new Hashtable();
    Hashtable party2 = new Hashtable();
    party1.put(WorkflowInstance.PARTYNAME_KEY, PARTY_SOURCE);
    party2.put(WorkflowInstance.PARTYNAME_KEY, PARTY_DEST);
    array[0] = party1;
    array[1] = party2;
    WorkflowInstance wi = new WorkflowInstance(BUSINESS_PROCESS_NAME,
    BUSINESS_PROCESS_MAJOR,
    BUSINESS_PROCESS_MINOR,
    BUSINESS_PROCESS_ROLE,
    array);
    "Mark Finlan" <[email protected]> wrote in message
    news:3b686b0f$[email protected]..
    >
    The documentation for starting a public workflow within an application isambiguous.
    At the following location:http://e-docs.bea.com/wlintegration/v2_0/collaborate/workflow/start.htm#1331
    638
    you state that a workflow instance is retrieved using the startWorkflowmethod.
    Unfortunately, this is a custom method that must be written and there isno suggested
    implementation.
    In terms of creating a workflow instance:
    For the WorkflowInstance class, there is only one documented constructor(although,
    there are 2 constructors). This constructor indicates that a HashtableArray of
    Party properties is a parameter. The documentation doesn't tell usspecifically
    what goes in these Hashtables, though. And as for the second constructor,we have
    no documentation and there is no mention in the API, but I do know that ittakes
    3 Strings as its parameters.
    How do I start a public workflow within an application?
    Thanks in advance,
    Mark

  • Recursive repaint() calls

    im trying to draw a nice recursive fractal thing, but first im making some sort of testing program
    im trying to make a routine which draws some sort of "fan" thing, composed by several lines which share the same origin point but different final y-coordinate
    what should we expect when running something like this?
    import javax.swing.*;
    import java.awt.*;
    import java.awt.geom.Line2D;
    public class Hola extends JPanel{
         private int y2;
         private JFrame frame;
         public Hola(){     
              frame= new JFrame("FRACTAL");
              frame.pack();
              frame.setSize(800,600);
              frame.setVisible(true);
              frame.setContentPane(this);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              lines(10);
         private void lines(int yf){
              System.out.println("hos "+yf);
              if(yf<60){
                   yf+=2;
                   y2=yf;
                   repaint();
                   lineas(yf);
         public void paintComponent(Graphics g){
              g.drawLine(10,10,300,y2);               
         public static void main(String [] args){
              new Hola();
    }i have seen this code paint nothing at all, painting all the "calculated" lines(i.e. all of them "showing" at the same time) and painting(showing) the last line, which i think is the expected behaviour (showing just the last line)
    now my question is
    how is supposed to be implemented any recursive painting algorithm?
    because i see that every repaint call will consequently "clean" everything already painted and replace it with the new painting routine, thus, making this kind of recursive approaches useless

    If you want all the objects drawn you must tell paintComponent to draw them all, so you must store all the previous values somewhere (in a hashtable, array or something) then iterate through them all in paintComponent

  • JSTL Working with collections

    Hi. I had a List in my page, and using JSTL could happily use <c:foreach /> to scan through it, and each of my objects in the List could succesfully be used for output with their setters and getters.
    Now I have a new situation where I have a Map, which contains a number of pairings of a Key to a List. Then each List contains one or more Maps. I need to use JSTL to work through the structure until I get a reference to the final Map. Can this be done?
    So I have...
    Map (key---->List)
    List--of several---Map
    I need ref to this map.
    Thanks!

    Hi,
    According to your description, you might want to gather all the SPWeb object into a collection object in order to delete all of them finally.
    As we can see, there is no such method in
    SPWebCollection object can meet you requirement, as a workaround, we can push all the SPWeb objects into an array, then operate
    these SPWeb objects in this array would do the trick.
    Here is a link about how to create a generic collection for a list of objects:
    http://www.andreasbijl.com/powershell-create-collections-of-custom-objects/
    More information about using collection in PowerShell:
    https://www.simple-talk.com/sysadmin/powershell/powershell-one-liners--collections,-hashtables,-arrays-and-strings/
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

  • How to obtain Hashtable element (array) base type?

    Hi,
         I have read the thread
              http://forum.java.sun.com/thread.jspa?forumID=52&threadID=531561
         on determining the base type of an object array.
         I tried applying the technique to my Hashtable where the element are arrays, this is how I am setting up my Hashtable to pass on to my native method
    Hashtable ht = new Hashtable();
    Float Kd[] = new Float[1];
    Kd[0] = 0.1f;
    Float from[] = new Float[3];
    from[0] = -4.0f;
    from[1] = 2.0f;
    from[2] = 1.0f;
    Integer indices[] = new Integer[4];
    indices[0] = 217;
    indices[1] = 17;
    indices[2] = 769;
    indices[3] = 23;
         myNativeMethod("dbname",ht);
         In my native method, I have the following which is able to determine the array size so I think it is kind of working/correct but when I tried to determine the base type of the array, I keep getting Bus error.
         Here is my native code (as part of my SWIG code)
         Should I be handling arrays obtained from Hashtable differently, can someone point out to me what the correct approach is?
    Regards
    8<------8<------8<------8<------8<------8<------8<------8<------
    if ($input != 0) {
    std::cout << "SWIG ...parameterlist..." << std::endl;
    // Generated typemap code
    const jclass hashtable = jenv->FindClass("java/util/Hashtable");
    if (hashtable != 0) {
    const jclass enumeration = jenv->FindClass("java/util/Enumeration");
    const jmethodID keys =
         jenv->GetMethodID(hashtable, "keys",
                   "()Ljava/util/Enumeration;");
    const jmethodID get =
         jenv->GetMethodID(hashtable, "get",
                   "(Ljava/lang/Object;)Ljava/lang/Object;");
    if (enumeration != 0) {
         const jmethodID hasMoreElements =
         jenv->GetMethodID(enumeration,
                   "hasMoreElements", "()Z");
         const jmethodID nextElement =
         jenv->GetMethodID(enumeration,
                   "nextElement", "()Ljava/lang/Object;");
         for (jobject keyset = jenv->CallObjectMethod($input, keys);
         jenv->CallBooleanMethod(keyset, hasMoreElements) == JNI_TRUE;) {
         jstring key = (jstring)jenv->CallObjectMethod(keyset, nextElement);
         jarray value = (jarray)jenv->CallObjectMethod($input, get, key);
         jclass valueClass = jenv->GetObjectClass(value);
         jclass valueClassClass = jenv->GetObjectClass(valueClass);
         const jmethodID getName =
         jenv->GetMethodID(valueClass,
                   "getName", "()Ljava/lang/String;");
         jstring valueClassClassName =
         (jstring)jenv->CallObjectMethod(value, getName);
         const char *vccptr = jenv->GetStringUTFChars(valueClassClassName,
                                  0);
         std::cout << "vccptr is " << vccptr << std::endl;
         jenv->ReleaseStringUTFChars(valueClassClassName, vccptr);
         const char *keyptr = jenv->GetStringUTFChars(key, 0);
         std::cout << "key is " << keyptr << std::endl;
         int numElements = jenv->GetArrayLength(value);
         std::cout << "value array size is " << numElements << std::endl;
         // const char *valptr = jenv->GetStringUTFChars(value, 0);
         // $1 = CSLAddNameValue($1, keyptr, valptr);
         jenv->ReleaseStringUTFChars(key, keyptr);
         // jenv->ReleaseStringUTFChars(value, valptr);
    8<------8<------8<------8<------8<------8<------8<------8<------
    Regards
    Message was edited by:
    nicholas_yue

    You've asked the same thing before. Assuming that you've defined the function prototype correctly when you built the DLL from the VI, you should be able to call it and get the results from it. You do not need to change the return type when you build the DLL. Read the information at http://zone.ni.com/devzone/conceptd.nsf/webmain/7D6A20FE02EDBF318625690700704CF3. Even though it was written for LabVIEW 6, the section on Accessing LabVIEW 6x Arrays from Microsoft Visual C++ is still valid.

  • Hashtable Vs Two Dimensional Array

    Hi!!!!!!!!!!!
    Can i use Hashtable intead of Two dimensioanal Array in my application.

    (After having had some coffee)
    There's just too many ways to do this to know what code to give you.
    Peter Lawrey gave you one possible answer. The issue is that you need to decide how you're going to combine two pieces of information (the row and column indices into a 2d array) into a single key value for looking up values in the hash. String concatenation is one way -- creating a java.awt.Point and declaring hash as
    Map<Point,String> logData = new HashMap<Point,String>();
    logData.put(new Point(x,y), value);
    String gotValue = logData.get(new Point(x,y));is another.
    You might also want a hash of hashes, but you can't get that as easily in java as you can in perl, as it won't invisibly create the necessary inner structures for you. You'd have to write a 'two dimensional' map class of your own (reasonably interesting idea, actually)

  • Converting a hashtable to an array (CORBA sequence)

    Hi all,
    I wish to convert the contents of a hashtable to an array (well a CORBA sequence), but I am having a bit of trouble.
    I have a CORBA struct called 'Equipment', and an unbounded sequence of Equipment structs called 'EquipmentList':
              struct Equipment {
                   string name;
                   string description;
              typedef sequence<Equipment> EquipmentList;I have a Java hashtable called equipmentList which contains a list of equipment with key 'name' and corresponding value of 'description'.
    The following code is trying to convert from the hashtable to the CORBA sequence:
              Equipment equipList[] = new Equipment[equipmentList.size()]; // make sequence same size as hashtable.
              for (int i = 0; i < equipmentList.size(); i++) {
                   equipList[i] = new Equipment(); // make element a valid 'Equipment' object.
                   equipList.name = equipmentList.name; // give each sequence element value 'name' the value of the hashtable key value 'name'
                   equipList[i].description = equipmentList.description; // same with 'description' value
    I know the conversion is completely wrong, and it obviously brings up 2 errors a compile time:HireCompanyServer.java:81: cannot find symbol
    symbol : variable name
    location: class java.util.Hashtable
    equipList[i].name = equipmentList.name;
    ^
    HireCompanyServer.java:82: incompatible types
    found : java.lang.Object
    required: java.lang.String
    equipList[i].description = equipmentList.get(equipList[i
    ].name);
    ^
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    2 errors
    I know this might be a long-winded question, but I am having real difficulty fixing this, and would kindly appreciate some more advanced programmers to give me any hints or fixes for my code.
    Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    JonBetts2004 wrote:
    I know this might be a long-winded question, but I am having real difficulty fixing this, and would kindly appreciate some more advanced programmers to give me any hints or fixes for my code.Not quite sure how 'struct' got in there, but unless you're using generics to set up your HashTable, you have to cast anything you get from your list to the correct type. Have a look at the HashTable method list and I think you'll work out what you want.

  • Hashtable and double array

    Hi,
    i need to store a series of double arrays in a hashtable.
    now while extracting them i get ClassCastException
    can anyone tell me how to extract a double array from a hashtable. if its not possible then can i use any other data structure
    thanx

    Cast it correctly?double[] darray = (double[])yourHashtable.get(yourKey);And if that doesn't work, then post the code where you put the "double array" into the Hashtable.

  • Array, Vector, or Hashtable?

    I'm wondering what the best way to populate a names list for a chat program is. I need it to be able to set a unique identification to whoever joins the chat. It has to be able to tell who left, and be able to take just that persons name out of the list.

    A Hashtable would let you match up user IDs to sockets, if that's your underlying design....

  • Array of hashtable

    Hi,
    Following is my code :
    -----------------Code starts here------------------------------------------------------------
    import java.util.Hashtable;
    public class Test{
    public static void main(String arg[]){
              Hashtable ht=new Hashtable();
              Hashtable[] hta=new Hashtable[3];
              ht.put("Country","Japan");
              ht.put("City","Tokyo");
              hta[0]=ht;
              ht.put("Country","India");
              ht.put("City","Delhi");
              hta[1]=ht;
              System.out.println(hta[0].get("Country"));
              System.out.println(hta[1].get("Country"));
    ----------------Code ends here-------------------------------------------------------------------
    And the result is....
    -----Output-----------------------
    India
    India
    -----Output ends here---------
    While I was expecting....
    Japan
    India
    Why hashtable in hta[0] is over-written ? How can I achieve the result (Japan, India) ?
    Thanks,

    ht.put("Country","Japan");
    ht.put("City","Tokyo");
    hta[0]=ht;After this, both hta[0] and ht are references to the same hashtable object
    ht.put("Country","India");
    ht.put("City","Delhi");Here, you are modifying the same object referenced by ht and hta[0]
    hta[1]=ht;Here ht, hta[0],hta[1] all reference the modified object and
    hence your result

  • Reading Values from a Hashtable.Please guideu

    Chaps,
    I am in a strange situation
    I am having a hashtable with the flwg values
    Entertainment Games
    Entertainment Video
    PIM Calculator
    Entertainment Jump
    Settings Set
    Entertainment Poker
    Now,I need to search this hashtable for the
    Object 'Entertainment' and whatever is the
    value of this,is put in an Array
    for this I am using:
    String s[];
    Enumeration e;
    for(int i=0; i<ht.size(); i++){
    String s = (String)ht.get("Entertainment");
    // I am stuck after this? Can some one please help?       
             

    Object value = ht.get("Entertainment");
    But if you are doing this (I can't tell if this is what you're doing from your first post, though):
    ht.put("Entertainment", onething);
    ht.put("Entertainment", anotherthing);
    ht.put("Entertainment", athirdthing);
    Then there will only be athirdthing in the table, cuz it'll overwrite the previous values.

Maybe you are looking for