Is it possible to declare method with non-finite argument list ?

Hi, everyone,
Is it possible to declare method with non-finite argument list
and to read values of these arguments inside this method ?
I'm not talking about main() method (i know it can), but
values to this method are passed through array. That won't do
do for me.
If it is possible, could someone show an example how to do this.

void method(Object[]o)
for (int i=0; i<o.length; i++)
if (oinstanceof Integer)
System.out.println("is is an integer: "+o[i]);
else if (o[i]instanceof Point)
System.out.println("is is an Point: "+((Point)o[i]).x+"/"+((Point)o[i]).y);
else if (o[i]instanceof String)
System.out.println("is is an String: "+o[i]);
if you call it like
method(new Object[]{new Integer(123), "Hello!", new Point(100, 200), "goodbye!"});then the method will output:
is is an integer: 123
is is an String: Hello!
is is an Point: 100/200
is is an String: Goodbye!
this is as powerful as varible parameter counts like in c, and it it typesafe.

Similar Messages

  • @protocol doesn't seem to work with non-primitive arguments

    Any idea why this works.
    CustomProtocol1.h
    @protocol CustomProtocol1
    - (void) start:(int) offset;
    @end
    But this doesn't:
    CustomProtocol2.h
    @protocol CustomProtocol2
    - (void) start:(CustomClass*) custom;
    @end
    The only difference is that CustomProtocol1 uses a non-primitve argument. Here is the error I get for CustomProtocol2: "Syntax error before 'CustomClass'. Method definition not in @implementation context"
    It seems CustomProtocol2 has problems finding the CustomClass.h but if I add #import "CustomClass.h" into CustomProtocol2.h I get this error: "Cannot find protocol declaration for 'CustomProtocol2'"
    So far, I can only conclude that Objective-C @protocol does not work with non-primitives.
    Any help would be MUCH appreciated.
    Anthony

    The compiler doesn't know what CustomClass is. You have to tell it. However, it is a pointer and, hence, actually is a "primitive" (AKA POD - plain 'ole data) type. So, you need to forward declare CustomClass like so:
    @class CustomClass;
    @protocol CustomProtocol2
    - (void) start:(CustomClass*) custom;
    @end

  • Input methods with non-java interface?

    Here's the problem,
    I have a C++ GUI which has 2 text fields. I need to be able to trap foreign characters in these text fields without touching any of the c++ code. That is, I need to use Java Input methods to do this. Any leads as to how to accomplish this?

    I don't think it's possible. Java IMF works with Java AWT and Swing text components only.

  • Text Messaging in Japanese (or other language with non-Roman script)

    Is it possible to send/receive text messages written in non-Roman characters with Verizon? 
    More specifically, I'm using a Droid 2 with Verizon, and I'm trying to text a friend in Japanese.  She has an iPhone (AT&T), and is physically in the U.S. (so I'm not asking about international text messaging).  I've already installed apps on my Droid (e.g. OpenWNN, or Simeji) to input Japanese, which work fine in and of themselves, and the Droid of course displays Japanese text or other languages just fine on the Browser or in E-mails.
    However, I'm having lots of trouble with Text Messaging.  When I send a message containing Japanese text (typed in perfectly fine with OpenWNN or whatever), she either never gets the message, or the text comes out unreadable (as ???????).  Messages with a mix of Roman and non-Roman characters typically show the Roman characters ok, but the non-Roman ones (i.e. Japanese) are garbled.  If she sends me a message containing any non-Roman characters, I generally don't get the message at all (i.e. not even garbled-- just no message at all).   This deficiency seems to be specific to Text Messaging, as far as I can tell.  I can send and receive e-mails containing Japanese just fine, read foreign language web pages, and type in Japanese into search boxes on those web pages and so on with the Droid.  However, sending an e-mail message to (myphone#)@vtext.com, predictably, results in any Japanese text being garbled, though Roman characters come through just fine.
    Is this perhaps something specific to Verizon's network?  Or is text messaging in non-Roman scripts just inherently impossible?  My friend says she knows others who can successfully text in non-Roman scripts (e.g. Korean Hangul, Japanese Kana or Kanji), and claims some of these folks are Verizon customers too.  A search on droidforums.com yielded someone who supposedly could text in Korean within Verizon.  So, I'm hoping this is possible, and I'm just missing something. However, this is perhaps all secondhand information and rumor.
    (Incidentally, I know for certain that messaging with non-Roman scripts is possible in general.  During my last vacation in Japan, I rented a phone there, and could send messages in English or Japanese scripts.  However, I believe the phones there actually have their own e-mail addresses, and so the service there is more like regular e-mail-- my understanding is that text messaging as we know it in the U.S. is a distinct technology, though I could well be wrong.)
    So, to restate my question: is it possible to text message with non-Roman scripts with Verizon?  Has anyone out there done this successfully-- if so what did you do, or what app did you use?  Or is it in fact impossible? (e.g. Maybe text messaging here only uses 7 or 8 bits, instead of 14 or 16 needed to encode all the various Asian, European, and other scripts?)
    Thanks for any help available.

    I'm trying to figure this out as well, but my understanding on the matter is that Verizon's CDMA network uses unicode which will display, roman characters, loa, thai, and serveral other languages, but not hirigana, kanji, katakana, or simplified or traditional chinese.  The Romaji should work however.  It would be nice to hear some input from a Verizon rep on the subject, because like you my info is all second hand.
    If my understanding is correct, the simple answer is no, it's not possible.  

  • Configuring IPIB with non-default partition key

    Hello
    I want to put IB HCA port into non-default partition to create separate network on my IB fabric. On IB switch (Voltaire ISR9096) I created network with non-default partition key 0x7ffe and add HCA port to this partition.
    But this IB-VPPA was displayed as unconfigured on Solaris host
    ib::3BA0001004181,ffff,ipib    IB-VPPA      connected    configured   ok
    ib::3BA0001004182,fffe,ipib    IB-VPPA      connected    unconfigured unknown
    ib::3BA0001004182,ffff,ipib    IB-VPPA      connected    configured   okConfiguration of new VPPA with cfgadm was unsuccessful:
    # cfgadm -c configure ib::3BA0001004182,fffe,ipib
    Configure the device: /devices/ib:fabric::3BA0001004182,fffe,ipib
    This operation will suspend activity on the IB device
    Continue (yes/no)? yes
    cfgadm: Hardware specific failure: configure operation failed ap_id: /devices/ib:fabric::3BA0001004182,fffe,ipibI unconfigured VPPA with default partition key (0xffff) on HCA port 0x3BA0001004182 and issued cfgadm for VPPA with pkey 0xfffe again - the same effect.
    I tried this on Solaris 10 8/07 and OpenSolaris b72 with the same result - no success ;)
    Is it possible to configure VPPA with non-default pkey on Solaris ?
    Is it possible to configure more than 1 IPIB VPPA on single HCA port ?
    How to perform these configurations ?
    Thanks in advance.
    Regards,
    Denis

    hi
    I was able to setup the listener to serve both databases using netmgr, thanks. Apparently I was trying to use the wrong tool for this previously.
    Now i'm able to access the EM Database Control and it seems to be working fine though i get the following error message
    Logged in As SYS
    Error
    java.lang.Exception: Number of responses does not match queries
    Database Instance: devel.foo.bar
    Now, i'd like to be able to use EM for administering two separate databases (running on the same host). Do i need to migrate the database control somehow to grid control? How do i do that?
    What about security? I'd like to use SSL and limit connections to selected clients only.
    regards,
    aspa

  • BC4J with non-SQL datasource

    Hi
    Is it possible to use BC4J with non-SQL, non-relational datasources? For example, we are exploring the possibility of using a file-based XML datastore (NOT the XDB) as the back-end for some ADF screens.
    Thanks,
    Sean

    BC4J is designed for SQL databases.
    http://www.oracle.com/technology/products/jdev/collateral/tutorials/903/j2ee_bc4j/prnt/j2ee_bc4j.html#bc4j-faq

  • Can WAE be integrated with non-cisco devices?

    So far, all documentation that I read, WAE is used in conjunction with Cisco devices.  Can WAE be integrated with non-cisco devices? 
    I guess, In-line mode should work ok, but how about off-path mode?  An example or link will be appreciated.
    Thanks!
    Joe

    Hi Joe,
    It should be possible to use WAAS with non-cisco routers, as long as they support WCCP.
    There are no documents on this because, the configuration from WAAS point of view would be the same, and the router configuration would depend on the vendor.
    Regards
    Daniel

  • Rhino calling overloaded Java methods with Array parameters

    Has anyone had any problems writing JavaScript code that calls overloaded Java methods?
    I have two Java defined methods that differ in the arguments, one takes a string the other takes an array of strings. The problem is calling Java methods within the JavaScript always calls the method with the String argument...
    /* Java Code Here */
    public void function(String s) { /* Function A */ }
    public void function(String[] sa) { /* Function B */ }
    /* JavaScript  Code Here */
    param = java.lang.reflect.Array.newInstance(java.lang.String, 2);
    param[0] = "test";
    param[1] = "test2";
    stringParam = "test3";
    /* Both function calls below end up calling the Function A from above */
    function(param);
    function(stringParam);PS...in case you're not familiar with Rhino,
    It is a mozilla package that embeds a JavaScript interpreter within a Java application...
    http://www.mozilla.org/rhino/

    haha...I can't even find my other thread :(
    Sorry about the double post...I'll go look for my other thread now

  • What is possible with non oracle components in the EMGC 10g release 3

    Hello,
    What is possible with non oracle components in the EMGC 10g release 3
    Our customer wants to also monitor and maintain non oracle components with EMGC 10g release 3.
    Some non oracle components are:
    Routers,
    Firewalls,
    Application Servers,
    Switches,
    Mail Servers,
    DNS/DHCP servers,
    Print Servers,
    File Servers,
    NTP,
    Citrix,
    Terminal Server,
    Lotus Notes,
    Etc etc.
    Is there a document on which non oracle components can be monitored in the EMGC and what can be maintained with these components?
    Regards,
    Tim Abdoelhafiezkhan

    Take a look into Plug-ins, there are some none-oracle ones pre built by Oracle and others.
    There's a forum about Extensibility in the current category here.
    Also, for further extensibility, the new Connector Framework looks interesting, see the OEM Integration Guide.

  • Non-varargs call of varargs method with inexact argument type for last para

    i have no idea what the error:
    non-varargs call of varargs method with inexact argument type for last parameter
    means.
    return (Component)sceneClass.getConstructor(
    new Class[]{int.class, int.class}).newInstance(
         new Integer[]{new Integer((int)sceneDimension.getWidth()),
                new Integer((int)sceneDimension.getHeight())});
    this is the problem area but i'm not sure how to get around it..
    any help would be appreciated

    I am a Java learner and I got the same warning. My code runs like this:
    import java.lang.reflect.*;
    class Reflec
         public static void main(String[] args)
              if(args.length!=1)
                   return;
              try
                   Class c=Class.forName(args[0]);
                   Constructor[] cons=c.getDeclaredConstructors();
                   Class[] params=cons[0].getParameterTypes();
                   Object[] paramValues=new Object[params.length];
                   for(int i=0; i<params.length; i++)
                        if(params.isPrimitive())
                             paramValues[i]=new Integer(i+3);
                   Object o=cons[0].newInstance(paramValues);
                   Method[] ms=c.getDeclaredMethods();
                   ms[0].invoke(o, null);
              catch(Exception e)
                   e.printStackTrace();
    class Point
         static
              System.out.println("Point class file loaded and an object Point generated£¡");     
         int x, y;
         void output()
              System.out.println("x="+x+"\ny="+y);
         Point(int x, int y)
              this.x=x;
              this.y=y;
    When I compiled the file I got the following:
    Reflec.java:26: warning: non-varargs call of varargs method with inexact argument type for last parameter;
    cast to java.lang.Object for a varargs call
    cast to java.lang.Object[] for a non-varargs call and to suppress this warning
    ms[0].invoke(o, null);
    ^
    1 warning
    Since the problem was with this line "ms[0].invoke(o, null);" and the specific point falls on the last argument as the warning mentioned that " ... method with inexact argument type for last parameter", I simply deleted the argument "null" and the line becomes "ms[0].invoke(o);" and it works, no warning anymore!
    DJ Guo from Xanadu
    Edited by: Forget_Me_Not on Jan 8, 2009 10:39 AM

  • Is it possible to declare an interface without any methods?

    Hi Guys!
    is it possible to declare an interface without any methods?
    Thanx
    -Sasi

    Of course, Serializable interface of Java is an example.

  • How can I change the payment method to None with gift card balance.

    How can I change the payment method to None with gift card balance?
    I already have an Apple ID account with no credit card but when I try to log in download free app it says Apple ID has not been used in iTunes store please review your account and it appears the billing info and there's no none in the option..how can I solve this so that I can used my Apple ID and can download free apps?

    Hi ..
    Help here >  Why can’t I select None when I edit my payment information?HHi

  • A question about a method with generic bounded type parameter

    Hello everybody,
    Sorry, if I ask a question which seems basic, but
    I'm new to generic types. My problem is about a method
    with a bounded type parameter. Consider the following
    situation:
    abstract class A{     }
    class B extends A{     }
    abstract class C
         public abstract <T extends A>  T  someMethod();
    public class Test extends C
         public <T extends A>  T  someMethod()
              return new B();
    }What I want to do inside the method someMethod in the class Test, is to
    return an instance of the class B.
    Normally, I'm supposed to be able to do that, because an instance of
    B is also an instance of A (because B extends A).
    However I cannot compile this program, and here is the error message:
    Test.java:16: incompatible types
    found   : B
    required: T
                    return new B();
                           ^
    1 errorany idea?
    many thanks,

    Hello again,
    First of all, thank you very much for all the answers. After I posted the comment, I worked on the program
    and I understood that in fact, as spoon_ says the only returned value can be null.
    I'm agree that I asked you a very strange (and a bit stupid) question. Actually, during recent months,
    I have been working with cryptography API Core in Java. I understood that there are classes and
    interfaces for defining keys and key factories specification, such as KeySpec (interface) and
    KeyFactorySpi (abstract class). I wanted to have some experience with these classes in order to
    understand them better. So I created a class implementing the interface KeySpec, following by a
    corresponding Key subclass (with some XOR algorithm that I defined myself) and everything was
    compiled (JDK 1.6) and worked perfectly. Except that, when I wanted to implement a factory spi
    for my classes, I saw for the first time this strange method header:
    protected abstract <T extends KeySpec> T engineGetKeySpec
    (Key key, Class<T> keySpec) throws InvalidKeySpecExceptionThat's why yesterday, I gave you a similar example with the classes A, B, ...
    in order to not to open a complicated security discussion but just to explain the ambiguous
    part for me, that is, the use of T generic parameter.
    The abstract class KeyFactorySpi was defined by Sun Microsystem, in order to give to security
    providers, the possibility to implement cryptography services and algorithms according to a given
    RFC (or whatever technical document). The methods in this class are invoked inside the
    KeyFactory class (If you have installed the JDK sources provided by Sun, You can
    verify this, by looking the source code of the KeyFactory class.) So here the T parameter is a
    key specification, that is, a class that implements the interface KeySpec and this class is often
    defined by the provider and not Sun.
    stefan.schulz wrote:
    >
    If you define the method to return some bound T that extends A, you cannot
    return a B, because T would be declared externally at invocation time.
    The definition of T as is does not make sense at all.>
    He is absolutely right about that, but the problem is, as I said, here we are
    talking about the implementation and not the invocation. The implementation is done
    by the provider whereas the invocation is done by Sun in the class KeyFactory.
    So there are completely separated.
    Therefore I wonder, how a provider can finally impelment this method??
    Besides, dannyyates wrote
    >
    Find whoever wrote the signature and shoot them. Then rewrite their code.
    Actually, before you shoot them, ask them what they were trying to achieve that
    is different from my first suggestion!
    >
    As I said, I didn't choose this method header and I'm completely agree
    with your suggestion, the following method header will do the job very well
    protected abstract KeySpec engineGetKeySpec (Key key, KeySpec key_spec)
    throws InvalidKeySpecException and personally I don't see any interest in using a generic bounded parameter T
    in this method header definition.
    Once agin, thanks a lot for the answers.

  • Archive Stock Cube with non-cumulative nature

    Hi All,
    I have been trying to archive the Inventory (Stock) Infocube as we have more than couple of hundread million records in the cube and it is taking long time to execute query.
    I know how to acrive the regular cubes and DSOs, but I couldn't find any helpful documentation where I can know how to archive the Infocube with non-cumulative nature or containing Marker update.
    Can anyone pleaes post the link of document?
    BTW, we are using BI7.0 SP15
    Thanks,
    Dhaval

    Hi,
    There are two ways of archiving data from a non-cumulative InfoCube - time slot archiving and archiving with selection characteristics.
    Time slot archiving (recommended)
    As an archiving method, you must choose for a non-cumulative InfoCube, time slot archiving for the time reference characteristic. When you recreate an archiving object for a non-cumulative InfoCube, this characteristic is also suggested by the system.
    Only archive non-cumulative changes up to a specific point in the past. This reduces the volume of data in the InfoCube. The marker (= end non-cumulative) remains unchanged.
    In the variants maintenance screen, in the archive administration, under Non-Cumulatives, choose the Movements Only option.
    You are only able to archive the marker if you also archive all of the non-cumulative changes. Subsequently, the contents of the non-cumulative InfoCube are archived completely. In the variants maintenance screen, in the archive administration, under Non-Cumulatives, choose the Movements and End Non-cumulative option.
    You must archive the non-cumulative changes (for all times) first, and then archive the marker in a separate archiving run, so that the non-cumulative changes and the marker are stored separately in the archive.
    The advantage of time slot archiving is that archiving runs can be carried out periodically using a single variant with a relative time restriction. The alternative archiving method described below does not have this advantage.
    Archiving with selection characteristics
    In some cases, archiving based only on time slots does not have the required effect of reducing the volume of data in the InfoCube. This is the case, for example, if the non-cumulative bearing objects are subject to high fluctuations, meaning that data is constantly being loaded for new objects and old objects are made obsolete. With time slot archiving, the end non-cumulative remains for all objects until all of the data in the InfoCube is finally archived, even if all the non-cumulative changes for an object have been archived already.
    In this case, you want to archive and delete completely any objects that are no longer active in the InfoCube. This means archiving the marker as well. For other objects that are still active, you only need to archive the non-cumulative changes from the past, which means the marker is retained.
    When you define the archiving properties for a non-cumulative InfoCube, do not therefore choose the time slot archiving method. Instead, select individually the characteristics that are relevant to restricting archiving runs. The time reference characteristic should also be included in this selection whenever possible.
    Using this archiving method, for each archiving run, you need to create selection conditions in a variant. In the variant for the archiving run, in addition to the selection conditions, you can also specify for the selected characteristics whether or not non-cumulative changes and marker data is archived. If you choose to archive marker data, be aware that the time selection contains the maximum value for time.
    Please refer to the below link to archive the data for Stock Cube:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/3f/c219fe9a46194aa66d55254fdab182/frameset.htm
    Hope this helps.
    Regards
    Tanuj

  • Static Methods with all Final Parameters

    Gurus,
    I know the synchronization and static method question has been hashed out ad infinitum here. However, I was thinking of a slight twist. (Did a search but could not find something related to this. If this has already been posted, my apologies).
    Suppose you have a static method in which all of the parameters in the method signature are declared final. Let's assume also that you are not performing an operation with a high latency (say, database or network operations).
    Would it be "safe" to leave the static method unsynchronized in a multi-threaded environment? Would the final keyword(s) ensure that, throughout method execution, there is no longer a race condition?
    Would there be a difference between a primitive:
    static final public void doSomething(final int param) {}
    And an object that has mutator methods:
    static final public void doSomething(final List param) {}
    Basically, not having a formal CS background, I'm not sure how static methods are actually invoked on a low-level. It probably varies across JVM's, and maybe this question doesn't make much sense. However, I thought I would throw this out to see if anyone had implemented something similar.
    I might be giving "final" too much credit., but what would actually happen in a multi-threaded environment?
    Thanks much!
    - Saish
    "My karma ran over your dogma." - Anon

    I know the synchronization and static method question
    has been hashed out ad infinitum here. What question's that then?
    Suppose you have a static method in which all of the
    parameters in the method signature are declared final.
    Let's assume also that you are not performing an
    operation with a high latency (say, database or
    network operations).
    Would it be "safe" to leave the static method
    unsynchronized in a multi-threaded environment?Whether or not the parameters are final makes no difference - method parameters are local to the method and so are only visible to the current thread anyway. So making them final will have no effect on anything goning on in any other thread.
    Whether or not you are performing operations has no effect on whether or not you can call a method thread-safe. It might mean there is less contention and it might make race conditions less likely, but it won't eliminate them.
    So the answer is: If your would be thread safe with non-final parameters, then it will still be thread-safe when the parameters are all final. If it is not thread-safe with non-final parameters, then it will still not be thread safe with final parameters.
    Would the final keyword(s) ensure that, throughout
    t method execution, there is no longer a race
    condition?No. Absoloutely not.

Maybe you are looking for