How can I implement a method to get any kind of class I want?

All I want is a method( or a class ) : getClassInstance().
i.e.
Vector v = someObj.getClassInstance("java.util.Vector");
or
Collection c = someObj.getClassInstance("java.util.Collection");
thanks!

Are you talking about this?://example - let's
use Vector
//NOTE - try...catch needed for these.
//Omitted here for clarity
Class myNewClass = Class.forName("java.util.vector");
Object myNewObject = myNewClass.newInstance();
Vector myNewVector = (Vector)myNewObject;
First, thank you very much for your answer!
But what I want is a method that can return any kind of class by input a class name.
Example :(maybe like this)
Vector v = getClassInstance("java.util.Vector");
Object getClassInstance(String ClassName) {
// code
return (ClassName)someObj;
If you have any idea about this question, please tell me the detail. Thanks again!

Similar Messages

  • How can i unlock my iphone to use any kind of phone network?

    how can i unlock my iphone to use any kind of phone network?

    Contact the carrier your phone is locked to to see if they offer official unlocking, & what the cost/procedure is. There is NO other way to get your phone officially unlocked, & Apple does not unlock iPhones.

  • How can i implement callback method in ejb?

    Hi all,
    Sir, i want to call a client method from ejbean how can i do it. in rmi we can do it to make a remote interface on client side but i use ejbean on client side it will need to run server also on client side thats doesn't seem good to me. have a solution to this problem.
    thanks,

    Your problem is little dicy
    in your case ejb calls the client's method where the very basic principle of J2ee is defeted
    any way your ejb can never call client i mean the end client
    there can be a situation where a ejb can call a client's method but in this case the client has to be another ejb say a session bean
    and both these beans are to be deployed on the same server
    if ur satisfied with this answer then i am waiting for my dukes

  • How can i change the method that get a Bitmap file and return 15 new Bitmaps so the new Bitmaps will be also PixelFormat Format8bppIndexed ?

    This is the method:
    public static Bitmap[] get_images_with_clouds(Bitmap radar_image)
    int e = 0;
    int f = 0;
    int image_clock_area_x = 0;
    int image_clock_area_y = 0;
    int image_clock_area_x1 = 140;
    int image_clock_area_y1 = 21;
    Bitmap[] localImages;
    localImages = new Bitmap[15];
    Bitmap image;
    image = new Bitmap(Properties.Resources.radar_without_clouds);
    BitmapData bmD = null;
    BitmapData bmD2 = null;
    try
    bmD = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
    bmD2 = radar_image.LockBits(new Rectangle(0, 0, radar_image.Width, radar_image.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
    IntPtr sc0 = bmD.Scan0;
    unsafe
    int* p = (int*)sc0.ToPointer();
    int* p2 = (int*)bmD2.Scan0.ToPointer();
    for (e = image_clock_area_x; e < image_clock_area_x + image_clock_area_x1; e++)
    for (f = image_clock_area_y; f < image_clock_area_y + image_clock_area_y1; f++)
    Color clock_color = Color.FromArgb(p2[e + f * bmD2.Width]);
    p[e + f * bmD.Width] = clock_color.ToArgb();
    image.UnlockBits(bmD);
    radar_image.UnlockBits(bmD2);
    catch
    try
    image.UnlockBits(bmD);
    catch
    try
    radar_image.UnlockBits(bmD2);
    catch
    int c;
    for (c = 0; c < localImages.Length; c++)
    localImages[c] = new Bitmap(image);
    Bitmap new_image = new Bitmap(Properties.Resources.radar_without_clouds);
    Bitmap new_image1 = new Bitmap(Properties.Resources.radar_without_clouds);
    Bitmap localbmptest = black_and_white(new_image, radar_image);
    Image image1 = black_and_white(new_image, radar_image);
    image1.Save(@"c:\temp\testclouds666.jpg");
    Bitmap clouds = new Bitmap(image1);
    int x;
    int y;
    int a;
    int b;
    int d = 0;
    Bitmap redImage;
    redImage = new Bitmap(512, 512);
    using (Graphics g = Graphics.FromImage(redImage))
    g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
    g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
    g.Clear(Color.Red);
    BitmapData bmData = null;
    BitmapData bmData2 = null;
    BitmapData bmDataArray = null;
    try
    bmData = clouds.LockBits(new Rectangle(0, 0, clouds.Width, clouds.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
    bmData2 = radar_image.LockBits(new Rectangle(0, 0, radar_image.Width, radar_image.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
    IntPtr scan0 = bmData.Scan0;
    IntPtr scan02 = bmData2.Scan0;
    unsafe
    int* p = (int*)scan0.ToPointer();
    int* p2 = (int*)scan02.ToPointer();
    double h, mm;
    for (d = 0; d < localImages.Length; d++)
    bmDataArray = localImages[d].LockBits(new Rectangle(0, 0, localImages[d].Width, localImages[d].Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
    IntPtr scan0Array = bmDataArray.Scan0;
    int* pArray = (int*)scan0Array.ToPointer();
    for (a = 0; a < new_image.Width; a++)
    for (b = 0; b < new_image.Height; b++)
    Color color1 = Color.FromArgb(p[a + b * bmData.Width]);
    Color color2 = Color.FromArgb(p2[a + b * bmData2.Width]);
    if (color1.R != 0 || color1.G != 0 || color1.B != 0)
    h = color2.GetHue();
    mm = RadarAnalysis.Hue2MMPerHour(h);
    if (mm >= treshhold_array[14 - d])
    pArray[a + b * bmDataArray.Width] = color2.ToArgb();
    localImages[d].UnlockBits(bmDataArray);
    clouds.UnlockBits(bmData);
    radar_image.UnlockBits(bmData2);
    catch (Exception error)
    try
    clouds.UnlockBits(bmData);
    catch
    try
    radar_image.UnlockBits(bmData2);
    catch
    try
    localImages[d].UnlockBits(bmDataArray);
    catch
    Logger.Write("Error Exception ==> " + error);
    MessageBox.Show("Error Exception ==> " + error);
    return localImages;
    In the end i'm getting 15 Bitmaps in localImages.
    localImages is Bitmap[]
    The method get a Bitmap and the Bitmap pixel format is: Format8bppIndexed
    I want that in the end the 15 Bitmaps in localImages will be also pixel format of Format8bppIndexed.
    The problem is that if i change everywhere in the method from: PixelFormat.Format32bppArgb to PixelFormat.Format8bppIndexed
    I'm getting exception on the line:
    pArray[a + b * bmDataArray.Width] = color2.ToArgb();
    Attempted to read or write protected memory. This is often an indication that other memory is corrupt
    System.AccessViolationException was unhandled
      HResult=-2147467261
      Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
      Source=My Weather Station
      StackTrace:
           at mws.ImagesComparison.get_images_with_clouds(Bitmap radar_image) in d:\C-Sharp\Download File\Downloading-File-Project-Version-012\Downloading File\ImagesComparison.cs:line 469
           at mws.ScanningClouds.backgroundWorker1_DoWork(Object sender, DoWorkEventArgs e) in d:\C-Sharp\Download File\Downloading-File-Project-Version-012\Downloading File\ScanningClouds.cs:line 695
           at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
           at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
           at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
           at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
           at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)
           at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
           at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
           at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
           at System.Threading.ThreadPoolWorkQueue.Dispatch()
           at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
      InnerException: 
    Line 469 is: pArray[a + b * bmDataArray.Width] = color2.ToArgb();

    Thorsten Hi,
    Too complicated for me i will try to look on it.
    Also if you will have time later maybe you could look at it too ? 
    For now what i tried was to get the returned 15 new Bitmaps to a local array:
    bitmaps = ImagesComparison.get_images_with_clouds(b1);
    for (int i = 0; i < bitmaps.Length; i++)
    ConvertTo1or8Bit.ColorToGrayscale(bitmaps[i]);
    break;
    Then make a convertion with a new class trying to convert the Bitmaps to 8 bit in the memory without saving them first to the hard disk. This is the new class:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Drawing.Imaging;
    using System.Drawing;
    using System.IO;
    namespace mws
    class ConvertTo1or8Bit
    public ConvertTo1or8Bit()
    public static Bitmap ColorToGrayscale(Bitmap bmp)
    int w = bmp.Width,
    h = bmp.Height,
    r, ic, oc, bmpStride, outputStride, bytesPerPixel;
    PixelFormat pfIn = bmp.PixelFormat;
    ColorPalette palette;
    Bitmap output;
    BitmapData bmpData, outputData;
    //Create the new bitmap
    output = new Bitmap(w, h, PixelFormat.Format8bppIndexed);
    //Build a grayscale color Palette
    palette = output.Palette;
    for (int i = 0; i < 256; i++)
    Color tmp = Color.FromArgb(255, i, i, i);
    palette.Entries[i] = Color.FromArgb(255, i, i, i);
    output.Palette = palette;
    //No need to convert formats if already in 8 bit
    if (pfIn == PixelFormat.Format8bppIndexed)
    output = (Bitmap)bmp.Clone();
    //Make sure the palette is a grayscale palette and not some other
    //8-bit indexed palette
    output.Palette = palette;
    return output;
    //Get the number of bytes per pixel
    switch (pfIn)
    case PixelFormat.Format24bppRgb: bytesPerPixel = 3; break;
    case PixelFormat.Format32bppArgb: bytesPerPixel = 4; break;
    case PixelFormat.Format32bppRgb: bytesPerPixel = 4; break;
    default: throw new InvalidOperationException("Image format not supported");
    //Lock the images
    bmpData = bmp.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly,
    pfIn);
    outputData = output.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.WriteOnly,
    PixelFormat.Format8bppIndexed);
    bmpStride = bmpData.Stride;
    outputStride = outputData.Stride;
    //Traverse each pixel of the image
    unsafe
    byte* bmpPtr = (byte*)bmpData.Scan0.ToPointer(),
    outputPtr = (byte*)outputData.Scan0.ToPointer();
    if (bytesPerPixel == 3)
    //Convert the pixel to it's luminance using the formula:
    // L = .299*R + .587*G + .114*B
    //Note that ic is the input column and oc is the output column
    for (r = 0; r < h; r++)
    for (ic = oc = 0; oc < w; ic += 3, ++oc)
    outputPtr[r * outputStride + oc] = (byte)(int)
    (0.299f * bmpPtr[r * bmpStride + ic] +
    0.587f * bmpPtr[r * bmpStride + ic + 1] +
    0.114f * bmpPtr[r * bmpStride + ic + 2]);
    else //bytesPerPixel == 4
    //Convert the pixel to it's luminance using the formula:
    // L = alpha * (.299*R + .587*G + .114*B)
    //Note that ic is the input column and oc is the output column
    for (r = 0; r < h; r++)
    for (ic = oc = 0; oc < w; ic += 4, ++oc)
    outputPtr[r * outputStride + oc] = (byte)(int)
    ((bmpPtr[r * bmpStride + ic] / 255.0f) *
    (0.299f * bmpPtr[r * bmpStride + ic + 1] +
    0.587f * bmpPtr[r * bmpStride + ic + 2] +
    0.114f * bmpPtr[r * bmpStride + ic + 3]));
    //Unlock the images
    bmp.UnlockBits(bmpData);
    output.UnlockBits(outputData);
    return output;
    But they are still 32 bit. So i guess i didn't realy understand yet how to do it.

  • Ow can i implement some method to perform task even if the user close

    Dear All
    I have a process need long time to complete , now how can i implement some method to perform this task even if the user close the browser??
    e.g
    if i have a button to update some value on one million recode which will take about 1 hour, is there a way to complete this update even if the user close his browser?

    Jaber,
    Sure, that works just fine too (having a Java application running). In order to "notify" it to run something, you can use whatever technology you like; if I were doing it, I'd probably use something like JMS backed by Oracle AQ to queue up tasks for it to do, however, that's just personal preference. You would have to design something that meets the needs of your particular use case. Perhaps another way would be to run it as a database job, in which case you can use the database scheduler to run it. There are probably one million and four different ways of doing it - the one you choose would depend upon your requirements and the technology you are comfortable with.
    John

  • How can I implement data type map?

    The getString() method of java.sql.ResultSet interface is not efficient enough.
    I want to map any data type to VARCHAR type,then use the getBytes() method to get the value.
    How can I implement it.
    I know proc can implement it, simply set selda->T[sli] with 1 for any field.

    Hello,
    What's your LabVIEW version ? Do you have a simple example program which demonstrates this behavior ?
    I found another discussions related to your issues with Xcontrols:
    updating type defs in Xcontrol Facade
    No Data Change event generated for a XControl in a Type Def
    XControl facede.vi 
    Hope this helps.
    Regards, 
    Steve M.
    National Instruments France
    #adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
    >> Vidéo-t'chats de l'été : présentations techniques et ingénieurs pour répondre à vos questions

  • How can i pass rowiterator method

    hi how can i pass rowiterator method
    i got below method how can i pass it to my postchanges mothod e.g
    SmsPropertiesImpl property = getSmsProperties();
    am in jdeveloper 11.1.2.1.0
    public class SmsPartyAddressImpl extends EntityImpl {
        public RowIterator getSmsProperties() {
            return (RowIterator)getAttributeInternal(SMSPROPERTIES);
        public void postChanges(TransactionEvent e) {
            /* If current entity is new or modified */
            if (getPostState() == STATUS_NEW ||
            getPostState() == STATUS_MODIFIED) {
            /* Get the associated property for the postaladdress */
           // SmsPropertiesImpl property = getSmsProperties();
            //SmsPropertiesImpl property  = getSmsProperties();
                SmsPropertiesImpl property = new SmsPropertiesImpl();
               // SmsPartyAddressImpl property = new SmsPartyAddressImpl();
            /* If there is an associated property */
            if (property != null) {
            /* And if its post-status is NEW */
            if (property.getPostState() == STATUS_NEW) {
            * Post the property first, before posting this
            * entity by calling super below
            property.postChanges(e);
            super.postChanges(e);
    }

    hi how can i pass rowiterator method
    i got below method how can i pass it to my postchanges mothod e.g
    SmsPropertiesImpl property = getSmsProperties();
    am in jdeveloper 11.1.2.1.0
    public class SmsPartyAddressImpl extends EntityImpl {
        public RowIterator getSmsProperties() {
            return (RowIterator)getAttributeInternal(SMSPROPERTIES);
        public void postChanges(TransactionEvent e) {
            /* If current entity is new or modified */
            if (getPostState() == STATUS_NEW ||
            getPostState() == STATUS_MODIFIED) {
            /* Get the associated property for the postaladdress */
           // SmsPropertiesImpl property = getSmsProperties();
            //SmsPropertiesImpl property  = getSmsProperties();
                SmsPropertiesImpl property = new SmsPropertiesImpl();
               // SmsPartyAddressImpl property = new SmsPartyAddressImpl();
            /* If there is an associated property */
            if (property != null) {
            /* And if its post-status is NEW */
            if (property.getPostState() == STATUS_NEW) {
            * Post the property first, before posting this
            * entity by calling super below
            property.postChanges(e);
            super.postChanges(e);
    }

  • How can I use QuickTime SDK to get Compress format of Video stream?

    I can get uncompress video stream like this:
    QDerr = NewGWorldFromPtr( &m_hGWorld, k32BGRAPixelFormat, &rcMac,
    NULL, NULL, 0, (char*)m_pVideoBuffer,
    m_sAVFileInfo.sResInfo.ulWidth*4);
    then the m_pVideoBuffer is uncompress video stream. How can I use QuickTime SDK to get Compress format of Video stream? I could change "k32BGRAPixelFormat" to other format,use other API or something?
    Could someone have the method? Best Wishes!

    Firefox, I would make sure you update your Desktop to Firefox 14.0.1, as the version you are running is quite old and out of date.
    Then, do you have your Sync Recovery key, username and password? If you do, you can re-add Firefox Sync to your computer.

  • How can i implement 'Distribute Qty' function in BAPI_GOODSMVT_CREATE

    Hi all,
    Using MIGO For GR. if more than one Batch or Production Date or Vendor Batch for same Purchase Order Line Item and Deliv date, need to hit ‘Distribute Qty’ button to split the entry line into multiple lines before enter Production Date and Vendor Batch.
    So I want use bapi BAPI_GOODSMVT_CREATE  implement MIGO function for a interface. Anyone have some suggestion how can i implement the 'Distribute Qty' function in the bapi.
    My email address: [email protected]

    Hello,
    1. Use structure BAPIPAREX for passing custom fields. (There are several blogs/posts on how to make use of this).
    2. In the BAPI i noticed there is a BAdI to populate these fields into your business tables.
    Call BAdI MB_BAPI_GOODSMVT_CREATE to fill own fields
        TRY.
            get badi lo_mb_bapi_GOODSMVT_CREATE.
          CATCH cx_badi_not_implemented.                    "#EC NO_HANDLER
        ENDTRY.
        TRY.
            call badi lo_mb_bapi_goodsmvt_create->extensionin_to_matdoc
              EXPORTING
                EXTENSION_IN = EXTENSIONIN[]
              CHANGING
                CS_IMKPF     = S_IMKPF
                CT_IMSEG     = T_IMSEG[]
                CT_RETURN    = return.
          CATCH cx_badi_initial_reference.                  "#EC NO_HANDLER
        ENDTRY.

  • How can we implement the currency translation in a query definition

    How can we implement the currency translation in a query definition and should it modified for each and every type of currencies

    hi rama krishna
    i think u can not get any translation in Query. this is only for het the report as it is there in tables. if u want to write a report take a help of the Abaper
    hope u goit,assign points if u ok for this
    thanks
    subbu

  • How can we implement SSO in SP2013

    Hi,
    How can we implement SSO from other applications to SP2013 web app.
    Please suggest with an example.
    Thanks,
    Krishna
    Krishnasandeep

    Basically  it is used to store credentials in a safe way. My article at
    http://sharepointdragons.com/2012/02/13/creating-a-bcs-net-assembly-connector/ discusses an example where it is leveraged within other SharePoint technology (BCS) but you can also use the object model to retrieve credentials and get login pages etc. for
    free provided by the Secure Store Service framework.
    Kind regards,
    Margriet Bruggeman
    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

  • How can we implement a regular expression in if condition?

    hi,
    could any body tell me how can we implement regular expression in if condition?
    if a page contains links with .html,.pdf,.img etc as href paths then i should only retrieve the links whose href path is .pdf .
    any idea
    thanks in advance

    Pasumarthi,
    Here is some VBA that should do the trick. This was created against the empirix homepage. www.empirix.com.
    Private Sub RSWVBAPage_afterPlay()
    Dim objReg As New RegExp
    Dim objMatch As Match
    Dim doc As String
    'Get the html
    RSWApp.GetHtml doc
    'set parameters for regular expression searching and matching
    With objReg
        'find all occurances
        .Global = True
        .IgnoreCase = True
        'regular expression pattern specified here
        .Pattern = "a href=(.+?)pdf"""
    End With
    'Loop through the matches and write them to the results log.
    For Each objMatch In objReg.execute(doc)
        RSWApp.WriteToLog objMatch.Value
    Next
    Set objReg = Nothing
    End Sub

  • Hi how can i implement the scenario.......plz reply asap.........

    HI folks,
    i have a typical problem in bex .
    my scenario is:i am having 2 values say 'x','y'.
    i want to implement a formula like x-y.
    if the x value is negative then i have to get the result as negative after the 'y' value get subtracted.if 'x' is positive, i have to get positive value after subtracting 'y' value.
    please let me know how can i implement this scenario in bex.
    by using a formaula or condition or anything else. please let me know clearly including the expression asap.
    Best reagards,
    ashok.

    answered

  • How can I implement GCM push notifications in AIR?

    How can I implement GCM push notifications in AIR? How can I implement GCM in Android using flex?

    You have 2 ways, first is buy the ane, are alot such as: http://myappsnippet.com/gcm/ or review the open in: https://github.com/freshplanet/ANE-Push-Notification or http://afterisk.wordpress.com/2012/09/22/the-only-free-and-fully-functional-android-gcm-na tive-extension-for-adobe-air/ , that for client side, for server side you can buy in http://urbanairship.com/ or enter in the world of build your own pisblisher server, in this case you need to read android and ios and blackberry notification, each one has different methods.
    Also, here you have more information: http://forums.adobe.com/message/4626292
    looks good.

  • How can I implement commands in Labwindows?

    I have a target with 8051 microprocessor. This microprocessor have a program in MS_DOS.
    I want to do an emulation with Labwindows.
    I comunicate with pc by RS232.
    In the MSDOS program I use the following commands:
    sp(back_espace key)= Initialitation board.
    vx(direction memory)(enter key)= Readed memory
    My question is: How can I implement commands in Labwindows?

    Hi,
    erm, could you re-post this question in the LabWindows/CVI forum?
    You might get a few more answers in there
    When you talk about emulating, I assume you're refering to getting Windows (which flavour - 9x/NT/me/xp/2k) to do some sort of display depending on button presses from a user interface, or are you wanting to turn the whole PC into an emulator, whereby another PC communicates to it through the serial port, and you want the emulating pc to react as though it was the 8051?
    Thanks
    S.
    // it takes almost no time to rate an answer

Maybe you are looking for