Generic problem in passing arguments  ( question )

I wrote some generic class that hold some generic map.
When i looking some key in this map - i want to have the value of the key and set this value to some argument that i pass to the function that look for it.
I dont want to return the value as return value of the function. ( i must have return value as Boolean )
My paroblem is that when ever i call this function - i get back the "value" as null - and i dont know why and how to solve this problem.
public abstract class SomeTable<T, U> extends Table{
      protected Map<T, U> currentTable = new HashMap<T, U>();
     public Boolean findItem(T itemToFind , U value){
            value = currentTable.get(itemToFind);
            return ( value == null );
}Edited by: Yanshof on Dec 3, 2008 6:02 AM
Edited by: Yanshof on Dec 3, 2008 6:11 AM

You don't want to get the value from the key, you want to set it. Something more like:
       public Boolean findItem(T itemToFind , U value){
           currentTable.put(itemToFind, value);
           return (value == null);
        }Maybe you should review the functionality of a HashMap and variable assignment..
Edit: Unless of course I'm misunderstanding your goal (ejp's post makes me think I am :) )
Edited by: Pheer on Dec 2, 2008 10:15 PM

Similar Messages

  • Problems with passing arguments to app

    Hi.
    I have a litle problem with passing arguments. I create a dynamic jnlp file using jsp. This is my code:
    <%
    response.setContentType("application/x-java-jnlp-file");
    String l = request.getParameter("login");
    String p = request.getParameter("pass");
    out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    out.println("<jnlp spec=\"1.0+\" codebase=\"http://212.244.104.27:8080/PzP_INSTALL/\" href=\"pzp.jsp\">");
    out.println("<information>");
    out.println("<title>xxx</title>");
    out.println("<vendor>xxxx</vendor>");
    out.println("<homepage href=\"main.jsp\"/>");
    out.println("<description>text</description>");
    out.println("<offline-allowed/>");
    out.println("</information>");
    out.println("<security>");
    out.println("<all-permissions/>");
    out.println("</security>");
    out.println("<resources>");
    out.println("<j2se version=\"1.4+\"/>");
    out.println("<jar href=\"jars/pzp.jar\" main=\"true\" download=\"eager\"/>");
    out.println("<jar href=\"jars/config.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/commons-beanutils.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/commons-collections.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/commons-digester.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/commons-logging.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/commons-validator.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/easclient.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/easj2ee.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/jakarta-oro-2.0.7.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/jbcl.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/log4j-1.2.7.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/jdom.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jars/xercesImpl.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<property name =\"javaws.login \"  " + "value=" + "\"" + l + "\"" + "/>");
    out.println("<property name =\"javaws.pass \"  " + "value=" + "\"" + p + "\"" + "/>");
    out.println("</resources>");
    out.println("<application-desc main-class=\"aaa.bbb.ccc.MyClass\"/>");
    out.println("</jnlp>");
    %>My problem is when i have the href tag filled, the arguments that i passed equlas null, when i remove the href everything is ok besides that the app doesnt show in application manager and doesnt create an icon on the desktop.
    out.println("<jnlp spec=\"1.0+\" codebase=\"http://62.89.104.27:8080/PzP_INSTALL/\" href=\"pzp.jsp\">");
    Any help would be appreciated.

    Hello again.
    Thanks for your replay but unfortunetly it doesnt work too :-(
    I've tried to use the out.println statemants in the servlet instead of using a jsp page but the error is the same. Please look at my code and tell me if you can what could be wrong.
    This is the error message:
    An error occurred while launching/running the application.
    Title: PZP
    Vendor: SPEED
    Category: Download Error
    Unable to load resource: http://212.89.104.27:8080/PzP_INSTALL/ServletPZP
    Servlet code.
    package pzp_install;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import pzp_install.LoginBean;
    import javax.swing.JOptionPane;
    public class ServletPZP extends HttpServlet {
      public void init(ServletConfig config) throws ServletException {
      super.init(config);
      config.getServletContext().setAttribute("ServletPZP", this);
      public void doPost(HttpServletRequest request, HttpServletResponse resp)
      throws IOException {
      PrintWriter out = resp.getWriter();
    // Get the value of the request parameter
      String login = request.getParameter("login");
      String pass = request.getParameter("pass");
    resp.setContentType("application/x-java-jnlp-file");
    out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    out.println("<jnlp spec=\"1.0+\" codebase=\"http://212.89.104.27:8080/PzP_INSTALL/\" href=\"/servletpzp\">");
    out.println("<information>");
    out.println("<title>PZP</title>");
    out.println("<vendor>SPEED</vendor>");
    out.println("<homepage href=\"main.jsp\"/>");
    out.println("<description>Aplikacja wspomagajaca zarzadzanie zleceniami</description>");
    out.println("<offline-allowed/>");
    out.println("</information>");
    out.println("<security>");
    out.println("<all-permissions/>");
    out.println("</security>");
    out.println("<resources>");
    out.println("<j2se version=\"1.4+\"/>");
    out.println("<jar href=\"pzp.jar\" main=\"true\" download=\"eager\"/>");
    out.println("<jar href=\"config.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"commons-beanutils.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"commons-collections.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"commons-digester.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"commons-logging.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"commons-validator.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"easclient.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"easj2ee.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jakarta-oro-2.0.7.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jbcl.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"log4j-1.2.7.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"jdom.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<jar href=\"xercesImpl.jar\" main=\"false\" download=\"eager\"/>");
    out.println("<property name =\"javaws.login \"  " + "value=" + "\"" + login + "\"" + "/>");
    out.println("<property name =\"javaws.pass \"  " + "value=" + "\"" + pass + "\"" + "/>");
    out.println("</resources>");
    out.println("<application-desc main-class=\"pl.speednet.pzp.PzP\"/>");
    out.println("</jnlp>");
      public void destroy() {
      super.destroy();
    This is the brief of code which starts the servlet
    <form action="http://212.89.104.27:8080/PzP_INSTALL/servletpzp" method="post">
      <input type="hide" name="login" value=<%=l%>>
      <input type="hide" name="pass" value=<%=p%>>
      <input type=submit value=Start PZP>
    </form>
    This is the web.xml file code.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
      <servlet>
        <servlet-name>ServletPZP</servlet-name>
        <servlet-class>pzp_install.ServletPZP</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>ServletPZP</servlet-name>
        <url-pattern>/servletpzp</url-pattern>
      </servlet-mapping>
      <mime-mapping>
        <extension>jar</extension>
        <mime-type>application/x-java-archive</mime-type>
      </mime-mapping>
      <mime-mapping>
        <extension>jnlp</extension>
        <mime-type>application/x-java-jnlp-file</mime-type>
      </mime-mapping>
    </web-app>

  • Problem passing arguments with air.swf

    I'm attempting to launch my AIR application using
    launchApplication() in air.swf. I'm having problems passing
    arguments to my application due to what appears to be some
    restriction in allowed characters. To get around this, I've even
    tried URL encoding and Base-64 encoding my arguments to make them
    more friendly, but it's still failing:
    Error: Invalid argument: PG5vIGlkZW50aWZpZXI+
    at AIR$/escapeArguments()
    at AIR/launchApplication()
    at
    adlm_launcher/onDownloadClick()[E:\adlm\launcher\src\adlm_launcher.mxml:181]
    It seems that any kind of punctuation is not allowed in
    arguments. URL encoding them doesn't work either because the % is
    rejected. Is there any other way around this?

    Yes; it's a security restriction. Browser invocation require
    process creation, and many process creation APIs giving special
    meanings to certain characters. Letting those characters through
    has in the past been a source of security vulnerabilities. While we
    also try to avoid using APIs with this behavior, extra layers of
    defense are also good.
    I think + and / may actually be safe choices; you make a good
    point that they're useful for Base64. If you could submit a feature
    request at www.adobe.com/go/wish, we'll definitely consider it.
    Another option, btw, is to use the LocalConnection API to
    pass data between the web page and your application once your app
    is launched. LocalConnection has fewer restrictions on the data
    passed.

  • Hi, i am facing problem as to how to pass arguments received by my swf file to an .exe that i have c

    hi, i am facing problem as to how to pass arguments received by my swf file to an .exe that i have created from a C++ project...do i need to tweak the code in the C++ project in some way that it accepts the input from the .swf file?

    Hi there and welcome to our community
    What you need to do is click the link below, then choose the forum most appropriate to the product you are using. In this forum we discuss the operation of the forums themselves.
    http://forums.adobe.com/index.jspa
    Best of luck to you in solving your issue! Rick

  • How to pass argument to the Java Plugin JVM w/o using the Control Panel?

    I want to deploy an applet to be loaded by the Java Plug In
    and fix some settings of its Java Virtual Machine.
    The JPI Control Panel offers two ways to pass arguments to the JVM,
    none satisfactory.
    1. while interactive via the Control Panel Window.
    This cannot be a solution for a deployed applet.
    or
    2. by editing the system generated file that stores
    the settings of the Plugin Control Panel, using a property
    named javaplugin.jre.params.
    The problem with this method is that if forces to access
    and edit this property file which is stored at various locations
    depending the client platform. Then, it may collide with other
    settings for other applets.
    Is there a way to pass the arguments to the JVM
    from within the html file?
    Has anyone found a solution to this question?
    JPS

    I am interested in this issue as well.
    Did anyone find a reliable way to specify the runtime parameters that should be used by the Java Plug-in in order to execute a given Java applet?
    I believe a good place to specify these runtime parameters would be the applet's JAR manifest: only digitally signed applets should be able to set the desired runtime parameters...
    Any comments / suggestion would be greatly appreciated.
    Regards,
    Marco.

  • How can we pass argument to static block of code????

    hi ,
    My question is we can use static initialization block for having functionality like constructors for initializing static variable ,but we cannot pass arguments to static initialization block then how can I create functionality like parametrized constructors.Whats the alternative shall I use a static method to perform this functionality,since all methods in given class are static and
    there is no need of creating instance of class.

    jduprez wrote:
    Hello Jussi,Salut Jérôme
    That's probably a more maintenable design.
    However what do you base your remark on - I'm struck by the word obviously?
    Is there some design principle from which this advice so naturally ensues that it is obvious ?Yes I read my posting later on and thought about changing it, since it's not necessarily an obvious solution. I was making assumptions that I didn't clarify from the OP.
    In the OP's case, the "state" on which those methods operate is apparently fixed, presumably at the beginning of the program, so what's wrong with all this staticness?
    I can list:
    - threading issues (a non-issue after some initialization phase), that you wouldn't have with immutable instances
    - harder unit-testing (that's not an OO design problem, more a methodology problem)
    - mix and confusion between static and non-static state if the class ever happens to have both, in future maintenance. All good points, I see all-static classes as a "code smell" and especially in this case when there's parametrization involved.
    Now we just need to have the OP explain his situation a bit better.

  • How can I pass arguments to a TestStand sequence with LabWindows 6 ?

    Hi
    I have created sequences in a TestStand file.
    I want to program a sequence with Labwindows 6 which would call all these existing sequences (containing parameters).
    I don't have any problems to create the steps "SequenceCall" but i don't know how to pass arguments to the sequences with the TS API.
    I have used the look-up strings "TS.SData.SFPath", "TS.SData.SeqName", "TS.SData.ThreadOpt" to program the sequence file / sequence and the multithread option. But now how to program the arguments passing ? I think there is something with the lookup string "ST.SData.ActualArgs"...
    Thank u very much for any help

    I'm not sure if you want to pass values from TestStand to LabWindows or if you want to pass values in TestStand from a sequence call step to a called sequence.
    To get TestStand variables from LabWIndows, use the following function:
    tsErrChk (TS_PropertyGetValNumber(testData->seqContextCVI, &errorInfo, "Locals.StartPoint", 0, &dStartPt));
    iStartPt = (int)dStartPt;
    The TS_PropertyGetValNumber gets the TestStand variable Locals.StartPoint and puts it into the LabWindows variable called dStartPoint. Numbers to and from Test Stand are always a double type. The next line converts it to an integer.
    To put a LabWindows value to TestStand, use TS_PropertyPutValNumber.
    To pass values from a sequence call step to a called sequence, create variables in the Parameters t
    ab on your main sequence. Create same variables on the Parameters tab of the called sequence. In main, specify module to be called in calling step. There is a paramters section on the Edit Sequence Call dialog box which appears. Check the Use Prototype of the Selected Sequence box. You can then list all the parameter variables in the parameters section.
    Hope this is what you want.
    - tbob
    Inventor of the WORM Global

  • I have a problem in the security question I hope a solution as soon as Lee does not respond change ÓćÇá Secretariat

    I have a problem in the security question I hope a solution as soon as Lee does not respond change ÓćÇá Secretariat

    Welcome to the Apple Community.
    Start here (change country if necessary) and navigate to 'Password and Security', reset your security questions using the link provided, you will receive an email to your rescue address, use the link in the email and reset your security questions.
    If that doesn't help, you don't receive a reset email or you don't have a rescue address, you should contact AppleCare who will initially try to assist you with a reset email or if unsuccessful will pass you to the security team to reset your security questions for you.
    If you are in a region that doesn't have international telephone support try contacting Apple through iTunes Store Support.

  • Pass arguments to JSF tag attributes like id oder value

    Hi!
    I started with JSF some weeks ago and have some questions that i could not find in FAQ or tutorials.
    My page structure uses some <jsp:includes>. Each included page uses JSF.
    The structure is (example - users):
    Users.jsp
    |
    |(incl)
    |
    Mainpage.jsp (=Framework)
    |
    |(incl)
    |
    Browser.jsp (=Table)
    In "Users" all specific data is set. In "Browser" there is a <h:form> tag and a <h:dataTable> tag.
    The result should be a simple table with users inside.
    So I want to pass arguments to those sub-pages.
    1) -> form-ids as parameter:
    <h:form id="#{sessionScope.formName}">
    ... does not work, because ids have to start with a character or "_".
    formName is set as followed:
    session.setAttribute("formName", "form_users");
    2) ->beans as parameter:
    <h:dataTable id="browser_table_#{sessionScope.id}" styleClass="browser_table"
    var="user" value="#{sessionScope.user_list}">
    ... does not work. "id" is requested to be a static value and "value" can't find the bean by this string.
    user_list is set as followed:
    session.setAttribute("user_list", "UserListBean.users");
    (UserListBean.users is an ArrayList)
    Is there an error in my thinking? Or is there a way to pass arguments as i want?
    Thanks!

    sorry ... mistake in topic: "oder" = "or" of course :)

  • How to execute adobe air app & pass argument from Flex ?

    Helo everyone,
    May i ask a question, How to execute adobe air app & pass argument from Flex ?
    Thanks in advanced.
    Jacky Ho.

    Hello Jacky,
    You can find an example here
    http://spreadingfunkyness.com/passing-parameters-to-adobe-air-at-startup/

  • Passing arguments to VBScript Program Object - Without WScript.Arguments?

    I am trying to create a program object with a VBScript that will change the name of a PDF created by a scheduled report. I need to be able to tack on the string "OH_2010_Qtr_1" (or whatever state - OH is used as an example) before the file extension - the VBScript creates that string based on the date the report is run. I want to be able to pass parameters to this script but when I try to do so I get the error "Variable is undefined 'WScript'" when trying to run the program object. I tried creating a batch file that would pass in the parameters and I get a generic error.
    How can I pass arguments to my VBScript? The arguments are necessary because this is for multiple instances of the same report, run for different states.

    For VBScript Program Objects, some injected objects:
    For Each arg in Script.Args
        ' Do something interesting with String arg here
        Script.Writeln(arg) ' Output to stdout
    Next
    and
    ' Get InfoStore
    Set infoStore = Session.Service("", "InfoStore")
    Sincerely,
    Ted Ueda

  • Pass arguments in a applet

    i know when you run a prog you could pass arguments, can i do with my applet.. like take a textbox in my html page?????

    thx man you're nice
    yes. you can do that. That is actually an <HTML>
    syntax question. Following might help
    <applet code="Chat" width=600 height=400>
    <param name=host value="somewhere.hotwired.com">
    <param name=port value="2323">and on the java side look at the APi and under Applet
    class look for getParameter() method

  • Passing arguments

    Our teacher just taught us about methods and passing arguments, etc. I have been over our text book and I don't quite understand how it works. Any help?
    PROBLEM:
    ?     Write a program with four methods. One is the main method. The other three are named startMessage, message, and finishMessage.
    ?     Within the startMessage method, place code to print out the message ?The program has started.?
    ?     Within the message method, place code to print out any message that is passed, as a String, into the method using a String parameter named output.
    ?     Within the finishMessage method, place code to print out the message ?The program is done.?
    ?     When the program begins call the startMessage method.
    ?     Then display the following dialog box:
    "Enter a message:"
    ?     Using a While loop, respond to the user?s input appropriately:
         If the user presses OK display whatever the user has entered by calling the message method with the user?s input as the argument. Continue to display the dialog box and display the user?s input until they press Cancel.
         When the user presses Cancel stop showing the dialog box, and do not display what the user has entered.
    ?     After the user presses Cancel, and before the program terminates, call the finishMessage method.
    ?     Terminate the program.
    here is what I have so far:
    public static void main(String[] args) {
              startMessage();
              String userMessage = JOptionPane.showInputDialog("Enter a message:");
              while (userMessage != null){
                   message(userMessage);
                   JOptionPane.showMessageDialog(null, "Here is message" + message());
                   userMessage = JOptionPane.showInputDialog("Enter a message:");
              finishMessage();
              System.exit(0);
         public static void startMessage(){
              JOptionPane.showMessageDialog(null, "The program has started.");
         public static String message (String output){
              output = userMessage;
              return(output);
         public static void finishMessage(){
              JOptionPane.showMessageDialog(null, "The program is done.");
    }what's giving me the problem is the message method; I can't figure out how to pass whatever they put in the userMessage variable to the message method

    I am stuck here
    PROBLEM:
    ?     Change your C6E2 class by adding a new method called getNumberInput. This method will be used to get a number input from the user, replacing the lines of code in the main method that were previously used. You will need to call this method twice from the main method, prompting for the first and second numbers in turn.
    ?     Write the method so that the prompt displayed in the input dialog box is passed through an argument.
    ?     The return type of this new method will be a double.
    I can't figure out how to pass the input paramater correctly, any help?
    public static void main(String[] args) {
              double num1 = 0;
              double num2 = 0;
              double addResult = 0;
              double subtractResult = 0;
              double multiplyResult = 0;
              double divideResult = 0;
              double input1 = getNumberInput(num1);//this is where I am stuck
              double input2 = getNumberInput(num2);
              addResult = add(num1, num2);
              subtractResult = subtract(num1, num2);
              multiplyResult = multiply(num1, num2);
              divideResult = divide(num1, num2);
              JOptionPane.showMessageDialog(null, addResult);
              JOptionPane.showMessageDialog(null, subtractResult);
              JOptionPane.showMessageDialog(null, multiplyResult);
              JOptionPane.showMessageDialog(null, divideResult);
              System.exit(0);
         }//main
         public static double getNumberInput (double input){
              double output = 0;
              Double.parseDouble(JOptionPane.showInputDialog("Enter a number:"));
              return output;
         public static double add (double term1, double term2){
              double result = term1 + term2;
              return result;
         }//add
         public static double subtract (double term1, double term2){
              double result = term1 - term2;
              return result;
         }//subtract
         public static double multiply (double term1, double term2){
              double result = term1 * term2;
              return result;
         }//multiply
         public static double divide (double term1, double term2){
              double result = term1 / term2;
              return result;
         }//divide
    }//class

  • Passing arguments in Visitor Pattern

    Does anybody have a nice solution to passing arguments in Visitor pattern?
    The Visitor pattern is used to process an object structure (such as an abstract syntax tree) in many different ways without cluttering definitions of the objects with methods needed for all different kinds of processing. Instead, each object has only one method, "void accept(Visitor v)". The method calls back a method in the Visitor that is appropriate for the object. Different kinds of processing use different Visitors, each with its own set of object-processing methods.
    My problem is that I need to pass arguments or receive results from the object-processing methods, different for different kinds of processing.
    One solution is to have many "accept" methods with different signatures. This beats the idea that we do not need to modify definitions of the objects if we want to introduce new kind of processing.
    Another is to provide "accept" with an Object result and a sufficient number of Object arguments, to be used as necessary by different Visitors. It results in clumsy and unreadable code. Detestable.
    Alternatively, one could provide fields in the objects to pass the information when needed. This frees the invocations of "accept" from dummy arguments/results, but does not seem nice.
    One can also forget all about Visitor pattern, and let the processing method test the object class using "instanceof" and call the right method. But this is a pure blasphemy against everything called OO.
    Is there any better way that I am too blind to see?

    Sounds to me like you've got a case of combining different concerns into the same design. I think you're looking at multiple problems, all of which require you to process an object structure.
    I'd make a general framework for processing my structure, and then use a specific interface for each problem. I would avoid re-using the Visitor pattern for multiple concerns as it leads to exactly the problems you're facing.
    If you're dead-set on using the Visitor; how about having a mediator or adapter between the visited class and the Visitor that deals with the specifics of each invocation?
    Personally, I think the Visitor pattern violates basic encapsulation and polymorphism - but that's just my opinion. I try to avoid using it unless I'm stuck with NO other solution.
    Good luck.

  • Passing arguments to a Global Activity with Instance Access

    I'm passing arguments to a Global Activity which has Instance access and then I need to assign agrument values to Instance variables. But, somehow arguments not being passed when I enable "Has Instance Access". If I turn instance access off then arguments pass but unfortunately I cannot assign due to instance not being available. Fyi, I'm using WAPI and argument names in HTML form are prefixed with "arg_" as per WAPI documentation.
    I would appreciate any help in resolving the issue.
    Thanks in advance.
    MK

    Same problem ...
    I tested with JSP.parameters["arg_myArg"] ... no result

Maybe you are looking for