Comparing Collection object with a string

Hi everyone,
There is my problem: I have a program that generate all possible combinations of a certain number of letters for example: -ABC- will gives A, B, C, AB, AC, BC, ABC. Everything is fine at this point. But then the user can input a string like "AB" and I have to tell him if this string is contained in the generated set. My set is in a Collection, but when I used : LetterCombination.Contains(TextString), it returns always false. Even if I know that the string is contained in the set.
Here is the code to generate the set:
public class Recursion
     Collection LetterCombination;
/*String Letters is the letters which I have to generate the combination, and
the LetterNumber is the number of letters contained in my string.*/
     public Recursion(Set ItemLetters, String Letters, int LetterNumbers)
          ItemLetters = new TreeSet();
String[] Token = Letters.split(" ");
/*Adding the letters in the TreeSet*/
for (int i = 0; i < LetterNumbers; i++)
     ItemLetters.add(Token);
LetterCombination = BuildLetterSet(ItemLetters);
private Collection BuildLetterSet(Set ItemLetters)
Set NotUsedYet = new TreeSet();
Set thisPowerSet = new TreeSet();
Collection Letterresult = new ArrayList();
NotUsedYet.addAll(ItemLetters);
BuildByRecursion(NotUsedYet, thisPowerSet, Letterresult);
return Letterresult;
private void BuildByRecursion(Set notUsedYet, Set thisPowerSet, Collection result)
if(notUsedYet.isEmpty())
if(!thisPowerSet.isEmpty())
Set copy = new TreeSet();
copy.addAll(thisPowerSet);
result.add(copy);
return;
Object item = notUsedYet.iterator().next();
notUsedYet.remove(item);
BuildByRecursion(notUsedYet, thisPowerSet, result);
thisPowerSet.add(item);
BuildByRecursion(notUsedYet, thisPowerSet, result);
thisPowerSet.remove(item);
notUsedYet.add(item);
And if I print out the LetterCombination collection, it gives me:
[C]
[B, C]
[A]
[A, C]
[A, B]
[A, B, C]
Which are the good combination needed. But I really don't understand how to compare this collection with the string entered by the user.
I'm really lost. can somebody help me! Thanks in advance...

You don't show where you call this constructor, or what your arguments are:
public Recursion(Set ItemLetters, String Letters, int LetterNumbers)
   ItemLetters = new TreeSet();
   String[] Token = Letters.split(" ");
   /*Adding the letters in the TreeSet*/
   for (int i = 0; i < LetterNumbers; i++)
      ItemLetters.add(Token[ i ]);
   LetterCombination = BuildLetterSet(ItemLetters);
}But, the constructor doesn't make sense, anyway. itemLetters is immediately set to a new TreeSet, so whatever you passed in (if anything) for the first argument is unchanged by the constructor (and the new TreeSet is lost when you finish the constructor). Also, you split your input Letters on space, but rely on LetterNumbers for the length of the split array (which may or may not be accurate). Why not do a 'for' loop testing for "i < Token.length", and eliminate LetterNumbers parameter? Your input for the second parameter to this constructor would have to be "A B C D" (some letters delimited by spaces). Your constructor only needs one parameter--that String.
The capitalization of your variables doesn't follow standard coding conventions. Your code is hard to read without the "code" formatting tags (see "Formatting Tips"/ [ code ] button above message posting box).

Similar Messages

  • Comparing table attribute with a string without compromising performance?

    in pl/sql what is the best practice for comparing a varchar2 attribute with a string should be case insensetive, without compromising performance.
    I've read on using an index (upper(tbl_attribute)) and then comparing in the where clause using
    upper(tbl_attribute) = input_value'
    is this the only way?
    is there a directive that could make the process faster?
    how about reading the table into memory then do the compare using upper in memory would that be faster than reading the table each time we run the comaprison condition?
    example:
    select name from tblnames
    where upper(name) = upper('Joe')
    thank you

    I would say the ideal case would be to ensure that all the data that is stored in the column is upper case to begin with. To monitor that you could place a constraint on the table like the following:
    ALTER TABLE TABLE_X ADD CONSTRAINT UPPER_CONS CHECK (COLUMN_X = UPPER(COLUMN_X));If the code can't be modified to always store the data in upper case you could always create a trigger to force the value to be upper case.
    Then your WHERE clause would only have to be like the following:
    COLUMN_X = UPPER('JOE')In my opinion storing the data as it should be would be the best performing because it should allow the CBO to have as many access paths as possible. You could then create a regular index on this column if there was truly a need for even better performance.
    A function-based index as you suggested is another viable option as well.
    HTH!

  • Naming an object with a string.

    Is it possible to make on object that is named with a String?
    so you make a string String a = "Hello";
    and then you make an object that is called Hello.
    Does anyone know?
    thx, SJG

    AFAIK, no. But depending on what you want to do, there are various ways of storing a String on the basis of another string received at runtime.
    A HashMap, for example, could use the String "Hello" as a key to get at another string:
    HashMap map = new HashMap();
    String inputA = "hello";
    String inputB = "to be stored";
    map.put(inputA, inputB);
    System.out.println(map.get(inputA));Perhaps that might be useful to you?

  • Problem with web service that returns an object with a String that have som

    Hi everybody:
    I have a problem with a web service I am doing, I have made a web service that returns a collection of objects, the objects have a set of properties, there is one property that is a String,this property consists in a text fragment that could have some characters that are considered special in XML like &, <, >, " and that's why when I execute the service from a client an exception is thrown:
    {code}
    Exception in thread "main" org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Could not read XML stream.. Nested exception is com.ctc.wstx.exc.WstxParsingException: Expected a text token, got START_ELEMENT.
    at [row,col {unknown-source}]: [9,646]
    org.codehaus.xfire.fault.XFireFault: Could not read XML stream.. Nested exception is com.ctc.wstx.exc.WstxParsingException: Expected a text token, got START_ELEMENT.
    at [row,col {unknown-source}]: [9,646]
    at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89)
    at org.codehaus.xfire.client.Client.onReceive(Client.java:410)
    at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139)
    at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
    at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
    at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
    at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
    at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114)
    at org.codehaus.xfire.client.Client.invoke(Client.java:336)
    at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
    at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
    at $Proxy0.search(Unknown Source)
    at cu.co.cenatav.webservices.client.Client.main(Client.java:26)
    {code}
    I know that this is happening because special characters are sent by the soap message but I don't know how to solve this problem.
    How could I avoid this exception ?
    I hope you can help me.
    Regards.
    Ariel

    Hi,
    BPEL and BPEL PM do not have a good support for SOAPENC-Array: it would be very difficult to create such an array in BPEL or to receive it and manipulate it.
    The (unfortunately very intrusive) work around is to change the WSDL of the service to use a XML type defined using XML schema. This is all the more painful that JDev 9.0.4 does not have strong support for complex types.
    In general though, I would highly recommend this best practice:
    1) Start by define the WSDL contract first
    2) Then generate the server side skeleton to implement it
    3) Use BPEL as the client to this contract.
    By starting with the contract first, you make sure that 1) your interfaces are clean and coarse grained.
    2) things like java objects, sessions, etc to not leak through the interface (which would be the worst thing that could happen because it would closely link the client and the server.
    Sorry for not being more helpful. This will get radically cleaner in Oracle AS 10.1.3.
    Edwin

  • Comparing text box with empty string

    Here is the procedure how to do it - but it does not work for me.
    http://blogs.adobe.com/captivate/2010/12/few-tips-on-%E2%80%98advanced-actions%E2%80%99.ht ml
    Could someone please confirm if the procedure mentioned in the blog is working or not, and if it's working, then what did I mess up in the first case below?
    In summary, I created a variable stringEmpty and created Advanced Action with condition associated with a button. I also created variable varUserName and associated it with a text box.
    There are 3 cases and 3 different behaviours.
    First case:
    stringEmpty =
    advanced action condition: varUserName; not equal to; stringEmpty (variable)
    After clicking the button, the result is as if the condition was always false (i.e. as if the string in the text box was always equal to stringEmpty)
    Second case:
    stringEmpty = aaa
    advanced action condition: varUserName; not equal to; stringEmpty (variable)
    After clicking the button, the condition is met when user enters "bbbbbbb" (which is OK). However, if he does not enter anything, only clicks the button, the condition is not met (which is incorrect behaviour, because "" <> "aaa" so the condition is met)
    Third case:
    advanced action condition: varUserName; not equal to; cccc (literal)
    In the third case all is OK.

    Hello,
    Each entry in a TEB has to be confirmed before it will get into the variable associated with it. This can be done with the Submit button or you can assign a shortcut key to it or use both. So I would really recommend to check if the variable is populated before you trigger your advanced action. You can do that by inserting temporarily a Text Caption that shows this user variable. Working with 2 TEB's on a slide: I tried to explain the workflow in another blog post:
    One submit button for multiple Text Entry Boxes
    To check if somewhere a scored object has been slipping in: check the Advanced Interaction view (F9)  which gives you an overview of all scored things.
    Lilybiri

  • URL object with https string throws malformed url exception: unknown protocol: https

    In WebLogic I am trying to connect to an HTTPS url by passing that url
    string into the contructor for URL object. This throws a Malformed URL
    Exception : unknown protocol: https.
    When i run this same block of code outside of weblogic (in a stand-alone
    app), it runs perfectly. (not exceptions when creating the URL object).
    why do i get this exception in weblogic?
    could weblogic be loading its own URL class rather than the java.net.URL
    class (which supports ssl)? if so how do i override that classloading?
    is there a weblogic security "feature" that prevents opening an ssl
    connection?
    thanks for any help
    mike
    [email protected]

    You need to modify your weblogic.policy file to allow you to change the
    the property java.protocol.handler.pkgs ... and any other properties
    that you may probably change using JSSE (for example:
    javax.net.ssl.trustStore for storing certificates of servers that you
    want to connect to from WLS )
    Regards,
    John Salvo
    Michael Harrison wrote:
    >
    thanks for the help dennis, but still get the "unknown protocol https".
    the URL object sees that the URLStreamHandler ==null and get the value for
    java.protocol.handler.pkgs (which should be
    com.sun.net.ssl.internal.www.protocol) then it tries to load that class. i
    believe that the GetPropertyAction("java.protocol.handler.pkgs","") is not
    returning com.sun.net.ssl.internal.www.protocol. therefore the class is not
    getting loaded
    i think that my classpath is set up properly for classpath and
    weblogic_classpath so i think that i me calling
    System.setProperty("java.protocol.handler.pkgs",
    "com.sun.net.ssl.internal.www.protocol"); is not effective.
    do you know anyway i can trouble shoot this.
    thanks
    mike
    Dennis O'Neill <[email protected]> wrote in message
    news:39d23c28$[email protected]..
    Https is an add-in so to speak. Try this before you create your url:
    System.setProperty ("java.protocol.handler.pkgs",
    "com.sun.net.ssl.internal.www.protocol");
    // add the default security provider (again, in JSSE1.0.1)
    int iap = java.security.Security.addProvider(new
    com.sun.net.ssl.internal.ssl.Provider() );
    dennis

  • Declaring an object with a string

    Is there a way to declare a data object (at runtime) from a
    string descriptor? For example, lets say I load a text file that
    contains the following string: "{name:"bob", age:42,
    location:"earth"}". Is there a way to then have Flash parse the
    string and interpret it as an Object object in memory?
    Thanks!

    This may be just what I need, thanks for the tip!
    I've set up a quick test though, and I'm having some
    problems. My code is as follows:
    import JSON;
    var str:String = "{'var1':'hello world'}";
    var obj:Object = JSON.parse(str);
    trace(obj.var1);
    All that I'm getting is an "[object Object]" trace in my
    output window (upon JSON.parse() calling). Scripts following the
    parse command do not run (ie: the trace action). And, if I try to
    access the obj object later (I was checking it upon a button
    press), then Flash is reporting that obj is undefined. Do you have
    any insight on this?
    Thanks for your help!!

  • Instantiating Object with NDS

    I'm having no success in instantiating object with NDS. Does anyone know whether is possible?
    I can hard code a statement as follows:
    pkg1.gs_nt(gs_nt.LAST) := NEW SomeObject_ot('x');
    where pkg1 is a package with the gs_nt variable declared in the spec. (global scope). The var. gs_nt is a nested table of SomeObject_ot type.
    When I try to use the same approach using NDS I get error messages at compile time:
    PLS-000103: Encountered the symbol "" - When I try to use the SomeObject_ot in a USING clause to set the value of a placeholder. In other words, it doesn't do the substitution.
    PLS-00382: expression is of wrong type - when I try to concatenate the object with a string.
    Based on the above, I've concluded that NDS can't be used to instantiate object types.
    Is thsi conclusion correct? Does anyone have a solution?

    Does this do what you need?
    SQL> create or replace type SomeObject is Object (
      2         val varchar2(10)
      3  ) ;
      4  /
    Type created.
    SQL>
    SQL> create or replace type SomeObject_nt is table of SomeObject ;
      2  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE PACKAGE pkg1 IS
      2      gs_nt someobject_nt;
      3      PROCEDURE initialize(p_var IN VARCHAR2,
      4                           p_obj IN VARCHAR2);
      5  END;
      6  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY pkg1 IS
      2      PROCEDURE initialize(p_var IN VARCHAR2,
      3                           p_obj IN VARCHAR2) IS
      4          str VARCHAR2(4000);
      5      BEGIN
      6          str := 'begin ' ||
      7                 '  ' || p_var ||'.EXTEND ; '||
      8                 '  ' || p_var || '(' || p_var ||'.LAST) := NEW ' || p_obj || '(:val) ; ' ||
      9                 'end ;';
    10          dbms_output.put_line('Count=' || pkg1.gs_nt.COUNT);
    11          EXECUTE IMMEDIATE str
    12              USING 'String';
    13          dbms_output.put_line('Count=' || pkg1.gs_nt.COUNT || ' pkg1.gs_nt(1).val='||pkg1.gs_nt(1).val);
    14      END;
    15  BEGIN
    16    gs_nt := SomeObject_nt() ;
    17  END;
    18  /
    Package body created.
    SQL> set serveroutput on size 100000
    SQL> exec pkg1.initialize(p_var => 'pkg1.gs_nt',p_obj => 'SomeObject') ;
    Count=0
    Count=1 pkg1.gs_nt(1).val=String
    PL/SQL procedure successfully completed.
    SQL>

  • How to compare 2 Objects( and )?

    Should I write an interface?

    Java has 2 interfaces that would be of interest to you.
    They both are designed to return an integer that describes the relationship between two objects.
    Suppose you have two objects: objectA and objectB
    The return value is as following:
    if (returnValue < 0) then objectA precedes objectB. (A < B)
    if (returnValue > 0) then objectA follows objectB. (A > B)
    if (returnValue == 0) then objectA and objectB are equivalent (A == B).
    It is up to you to do the comparing and determine which is the correct return value...
    Here are the two interfaces:
    1) Comparable interface (java.lang.Comparable)
    You would use this interface when you have a class that exhibits some natural order..
    You add this interface to the class, and, within the class, implement the following method:
       public int compareTo( Object obj )
       The variable obj in this case refers to the "other" object that you want to compare.
       public class MyClass implements Comparable // <--- notice the last two words!!
              other methods.
          public boolean isTallerThan( MyClass mc )
             // just some method i made up to compare...
          public int compareTo( Object objectB )
             // You are comparing "this" object with the "otherObject"...
             // Note that objectA is "this".
             MyClass otherObject = (MyClass)objectB;
             // Do whatever you need to compare the two.
             if (this.isTallerThan(otherObject) )
                 return -1;
             else if ( otherObject.isTallerThan(this) )
                 return +1;
             else
                 return 0; // they are of equal height...whatever...
       2) Comparator interface (java.util.Comparator)
    You could use this interface if you have a different set of standards with which to compare two different objects. Usually, it is it's own class, designed for only this purpose. You implement the following method:
       public int compare( Object objA, Object objB )
       Notice that in this case you have to explicitly pass in both objects to be compared, whereas in the Comparable interface, objA is implicitly assumed to be the object on which the method is called (or as I like to call it, this).
    Here is an example:
       public class MyComparator implements Comparator
          public int compare( Object objA, Object objB )
             do whatever comparisons you need to determine whether
             objA < objB (-1 is returned)
             objA > objB (+1 is returned)
             or
             objA == ObjB (0 is returned)

  • Encryt with a String

    Hi all
    This is the first time that I'm trying to use de cryto api, but my purpose is to encrip a object with a String of my, and then serialize it.
    I've found the following example on the net:
    try {
    // Generate a temporary key. In practice, you would save this key.
    // See also e464 Encrypting with DES Using a Pass Phrase.
    SecretKey key = KeyGenerator.getInstance("DES").generateKey();
    // Prepare the encrypter
    Cipher ecipher = Cipher.getInstance("DES");
    ecipher.init(Cipher.ENCRYPT_MODE, key);
    // Seal (encrypt) the object
    SealedObject so = new SealedObject(new MySecretClass(), ecipher);
    // Get the algorithm used to seal the object
    String algoName = so.getAlgorithm(); // DES
    // Prepare the decrypter
    Cipher dcipher = Cipher.getInstance("DES");
    dcipher.init(Cipher.DECRYPT_MODE, key);
    // Unseal (decrypt) the class
    MySecretClass o = (MySecretClass)so.getObject(dcipher);
    } catch (java.io.IOException e) {
    } catch (ClassNotFoundException e) {
    } catch (javax.crypto.IllegalBlockSizeException e) {
    } catch (javax.crypto.BadPaddingException e) {
    } catch (javax.crypto.NoSuchPaddingException e) {
    } catch (java.security.NoSuchAlgorithmException e) {
    } catch (java.security.InvalidKeyException e) {
    But i like to use it with my own key (String object), anyone knows which changes need to be performed?

    This is my standard DES example -
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import java.security.*;
    import sun.misc.*;
    public class DESEncryptDataString
        static public class EncryptionException extends Exception
            private EncryptionException(String text, Exception chain)
                super(text, chain);
        public DESEncryptDataString(byte[] keyBytes, byte[] ivBytes, String characterEncoding) throws EncryptionException
            assert (keyBytes != null) && (keyBytes.length == 8);
            assert (ivBytes != null) && (ivBytes.length == 8);
            assert (characterEncoding != null);
            try
                SecretKey key1 = new SecretKeySpec(keyBytes, "DES");
                // To demonstrate that the least significant bit is the parity bit and can be ignored.
                keyBytes[0] ^=0x01;
                SecretKey key2 = new SecretKeySpec(keyBytes, "DES");
                IvParameterSpec iv = new IvParameterSpec(ivBytes);
                this.characterEncoding = characterEncoding;
                this.encryptCipher = Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE");
                this.encryptCipher.init(javax.crypto.Cipher.ENCRYPT_MODE, key1, iv);
                this.decryptCipher = Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE");
                this.decryptCipher.init(javax.crypto.Cipher.DECRYPT_MODE, key2, iv);
            catch (Exception e)
                throw new EncryptionException("Problem constucting " + this.getClass().getName(), e);
        synchronized public byte[] encrypt(String dataString) throws EncryptionException
            assert dataString != null;
            try
                byte[] dataStringBytes = dataString.getBytes(characterEncoding);
                byte[] encryptedDataStringBytes = encryptCipher.doFinal(dataStringBytes);
                return encryptedDataStringBytes;
            catch (Exception e)
                throw new EncryptionException("Problem encrypting string", e);
        synchronized public String decrypt(byte[] encryptedDataStringBytes) throws EncryptionException
            assert encryptedDataStringBytes != null;
            try
                byte[] dataStringBytes = this.decryptCipher.doFinal(encryptedDataStringBytes);
                String dataString = new String(dataStringBytes, characterEncoding);
                return dataString;
            catch (Exception e)
                throw new EncryptionException("Problem decrypting string", e);
        public static void main(String[] args)
            try
                // Make sure SUN are a valid provider
                Security.addProvider(new com.sun.crypto.provider.SunJCE());
                // The DES Key - any 8 bytes will do though beware of weak keys.
                // This could be read from a file.
                final byte[] keyBytes = "01234567".getBytes("ASCII");
                // IV For CBC mode
                // Again, could be read from a file.
                final byte[] IVBytes = "ABCDEFGH".getBytes("ASCII");
                // Data string encrypt agent that assumes the data string is only ASCII characters
                DESEncryptDataString dataStringEncryptAgent = new DESEncryptDataString(keyBytes, IVBytes, "UTF-8");
                // Get the data string to encrypt from the command line
                String dataString = (args.length == 0)? "The quick brown fox jumps over the lazy dog." : args[0];
                System.out.println("Data string ....................[" + dataString + "]");
                byte[] encryptedDataStringBytes = dataStringEncryptAgent.encrypt(dataString);
                BASE64Encoder base64Encoder = new BASE64Encoder();
                System.out.println("Encoded encrypted data string ..[" + base64Encoder.encode(encryptedDataStringBytes) + "]");
                String recoveredDataString = dataStringEncryptAgent.decrypt(encryptedDataStringBytes);
                System.out.println("Recovered data string ..........[" + recoveredDataString + "]");
            catch (Exception e)
                e.printStackTrace(System.out);
        private String characterEncoding;
        private Cipher encryptCipher;
        private Cipher decryptCipher;
    }Please note, DO NOT TRY TO CONVERT THE ENCRYPTED DATA TO A STRING USING
    String encryptedDataAsString = new String(encryptedDataStringBytes)
    as not all bytes and byte sequences can be recovered from teh resulting String. The result depends on the encoding.
    If you need a String representation then use Base64 or Hex encoding.

  • How do you add an object to a collection typed witha wildcard?

    Hi All,
    I want to add an object to a collection typed with a wildcard but I can't figure out how to do it.
    I've been thru the generics tutorial again and I now understand that I can't do exactly what I want to and why. However I don't know how to do it right. I copy some code below to show the problem:
    private List<? extends HasCriteria> dataList;
    private HasCriteria dataObject;
    public HasCriteria getDataObject() {
            return dataObject;
    public List<? extends HasCriteria> getCollection() {
            if(dataList==null){
                refreshDataCollection();
            return dataList;
       }/*I want to be able to do the add() below but the generics tutorial assures me, as does the compiler, that I can't. So how do I get an object into the collection?? */
    public void create(){
    getCollection().add(getDataObject());
    }/*I don't understand why I can do this setCollection() call below as the compiler has no idea that the resultList is of type HasCriteria, however I accept that it is ok with this*/
    protected <T extends HasCriteria> void setCollection(Collection<T> m) {
                dataList = new ArrayList<T>(m) ;
                for(HasCriteria t: dataList){
                    t.setStatus(HasCriteria.Status.SAVED);
    public void refreshDataCollection(String jpaQL, List modelParameters){
                Query q = em.createQuery(jpaQL);
                List rl = q.getResultList();
                if(rl != null){
                    setCollection(rl);
                    setModelQuery(jpaQL, modelParameters);  
    }

    class GenGen <K extends Shape> {
      private List<K> dataList;
      private K dataObject;
      public K getDataObject() {
        return dataObject;
      public List<K> getCollection() {
        if(dataList==null){
          //refreshDataCollection();
        return dataList;
      public void create(){
        getCollection().add(getDataObject());
      protected void setCollection(Collection<K> m) {
        dataList = new ArrayList<K>(m) ;
        for(Shape t: dataList){
          // t.setStatus(HasCriteria.Status.SAVED);
      public void refreshDataCollection(String jpaQL, List modelParameters){
        List rl = null;
        setCollection(rl);
    }Note that in that final setCollection, you'll get an unchecked conversion warning, if you haven't turned them off.

  • Comparing string delimited by semicolon in a column with another string

    Hi
    I have requirement like comparing a column which contains the string delimited by semi colon with a string delimited by semicolon. i.e. comparing the multiple values with multiple values.for this purpose i am using the following code
    select ams.application_id,it_mgmt_chain
    FROM tb_ams038_application ams,THE
    (SELECT CAST
    (Appmgmt_Str_To_Table
    (NVL (ams.it_mgmt_chain,
    ) AS appmgmt_tabletype_string
    FROM DUAL
    AND (COLUMN_VALUE IN ( SELECT COLUMN_VALUE
    FROM THE
    (SELECT CAST
    (Appmgmt_Str_To_Table
    (nvl(NVL (replace('1234;8383;83939;93939',',',';'),
    ams.it_mgmt_chain
    ) AS appmgmt_tabletype_string
    FROM DUAL
    here in the above it_mgmt_chain has the string containing numbers seperated by semi colon. and the Appmgmt_Str_To_Table function used to split the string and return it in the form of list. and appmgmt_tabletype_string is a varray which is created for spliting and storing purpose.
    Can anyone please suggest the best way to do this task as the above code is giving a performance issue.

    This example uses a "|" not a semicolon but it leverages the REGEXP_SUBSTR, SUBSTR, LENGTH to perform a parsing action.
    http://blog.mclaughlinsoftware.com/plsql-programming/a-result-cache-function-returning-a-collection/
    You may wish to remove the "THE" and replace it with "TABLE" too. Good luck.

  • How to encrypt with a string as input,but not a key object

    As far as I know,when encrypt or decrypt ,a key must first be got,and the key is first generate by a tool or from SecurityRandom,that means I can not generate the same key with the same input.Does there is a method which can generate a same with the same input string?
    There is a need to transfer file between to site,and the customer wish to encrypt these files during transfering,and they want to store a string into each database at each site,when sending and receiving files,get the string from the database to encrypt or decrypt the file,they alse want to have a control of the string,they can change the string randomly if they wish as long as long keep each string is equal,how to realize this?

    I think what you are looking for is a password based encryption (PBE). An example of using the same is mentioned in JCE reference guide. Below is the relevant code/docs from the rference guide.
    Using Password-Based Encryption
    In this example, we prompt the user for a password from which we derive an encryption key.
    It would seem logical to collect and store the password in an object of type java.lang.String. However, here's the caveat: Objects of type String are immutable, i.e., there are no methods defined that allow you to change (overwrite) or zero out the contents of a String after usage. This feature makes String objects unsuitable for storing security sensitive information such as user passwords. You should always collect and store security sensitive information in a char array instead.
    For that reason, the javax.crypto.spec.PBEKeySpec class takes (and returns) a password as a char array.
    The following method is an example of how to collect a user password as a char array:
         * Reads user password from given input stream.
        public char[] readPasswd(InputStream in) throws IOException {
            char[] lineBuffer;
            char[] buf;
            int i;
            buf = lineBuffer = new char[128];
            int room = buf.length;
            int offset = 0;
            int c;
    loop:   while (true) {
                switch (c = in.read()) {
                  case -1:
                  case '\n':
                    break loop;
                  case '\r':
                    int c2 = in.read();
                    if ((c2 != '\n') && (c2 != -1)) {
                        if (!(in instanceof PushbackInputStream)) {
                            in = new PushbackInputStream(in);
                        ((PushbackInputStream)in).unread(c2);
                    } else
                        break loop;
                  default:
                    if (--room < 0) {
                        buf = new char[offset + 128];
                        room = buf.length - offset - 1;
                        System.arraycopy(lineBuffer, 0, buf, 0, offset);
                        Arrays.fill(lineBuffer, ' ');
                        lineBuffer = buf;
                    buf[offset++] = (char) c;
                    break;
            if (offset == 0) {
                return null;
            char[] ret = new char[offset];
            System.arraycopy(buf, 0, ret, 0, offset);
            Arrays.fill(buf, ' ');
            return ret;
        }In order to use Password-Based Encryption (PBE) as defined in PKCS #5, we have to specify a salt and an iteration count. The same salt and iteration count that are used for encryption must be used for decryption:
        PBEKeySpec pbeKeySpec;
        PBEParameterSpec pbeParamSpec;
        SecretKeyFactory keyFac;
        // Salt
        byte[] salt = {
            (byte)0xc7, (byte)0x73, (byte)0x21, (byte)0x8c,
            (byte)0x7e, (byte)0xc8, (byte)0xee, (byte)0x99
        // Iteration count
        int count = 20;
        // Create PBE parameter set
        pbeParamSpec = new PBEParameterSpec(salt, count);
        // Prompt user for encryption password.
        // Collect user password as char array (using the
        // "readPasswd" method from above), and convert
        // it into a SecretKey object, using a PBE key
        // factory.
        System.out.print("Enter encryption password:  ");
        System.out.flush();
        pbeKeySpec = new PBEKeySpec(readPasswd(System.in));
        keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
        SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);
        // Create PBE Cipher
        Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");
        // Initialize PBE Cipher with key and parameters
        pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec);
        // Our cleartext
        byte[] cleartext = "This is another example".getBytes();
        // Encrypt the cleartext
        byte[] ciphertext = pbeCipher.doFinal(cleartext);Hope this helps
    Sai Pullabhotla

  • Comparing a class with Class-Object

    Hi there:
    I receive a Class-Object and have to compare it
    with a class, for example:
    public boolean stringClass(Class cl) {
      if (cl.equals("".getClass))
        return true;
      else
        return false;
    }I don't like this because in case of complex objects I have
    to create this object only for comparing, it's very inefficient:
    public boolean specialClass(Class cl)
       return cl.equals((new Special(<many parameters .. >)).getClass());
    }Any idea? Am I simply confused to see a clear solution?
    I will prefer something like this:
    if ( cl == Special.getClass())Thanx
    Andreas

    If you have an object, for example a String object, then you can check if this object is really a String:
    Object o = new String("");
    if (o instanceof String) {
      System.out.println("The object is a String");
    }Can you use that, or do you really want to test if a Class object is the name of a given class?
    Class cl = String.class;
    if (cl.getName().equals("java.lang.String")) {
      System.out.println("String Class");
    }

  • Create an object with the name passed in as a string argument to a method

    Hi,
    I am sorry if it's too trivial for this forum , but I am stuck with the following requirements.
    I have a method
    void abc(String object_name, String key, String value)
    method abc should first check if there exists in memory a hashmap object with the name passed in as argument object_name.
    If yes ..just put the key and value there.
    if not , then create the hashmap object called <object_name> and insert the key/value there.
    Can anybody help me in the first step i.e, how to check if an object exists with the name passed in and if not then create it.
    Will getInstance method be of any help?
    Thanks in advance for your response.
    -Sub-java

    Dear Cotton.m,
    Thanks for your suggesstion. I will remember that.
    But somehow I have a strong belief that you still need to consult dictionary for exact meaning of the words like "upset" , "frustration" etc. Not knowing something in a language , that too as a beginner, does not yield frustration, but increases curiosity. And people like petes1234 are there to diminish that appetite.
    To clarify above, let me compare jverd's reply to my doubt with petes1234's.
    jverd said it cannot be done and suggested a work around (It was perfect and worked for me) While petes1234 , having no work in hand probably, started analysis of newbies mistakes.
    jverd solved my problem by saying that it cannot be done. petes1234 acted as a worthless critic in my opinion and now joined cotton.m.
    Finally, this is a java forum and I do not want to discuss human characteristics here for sure.
    My apologies if I had a wrong concept or if I chose a wrong forum to ask, where people like petes1234 or Cotton.m show their geekdom by pointing out "shortfalls" rather than clearing that by perfect examples and words.
    Again take it easy and Cotton.m , please do not use this forum to figure out others' frustration but be a little more focussed on solving others "Java related" problems :)
    -Sub-java

Maybe you are looking for

  • Partner profile not available.

    Dear Folks, i am doing the scenario JDBC to IDOC. For that i did all the necessary ALE settings and configured the systems. While executing that scenario. In we02, i am getting the error partner profile not available eventhough i configured it. From

  • Upgrade procedure for apex to 4.1 on 10.2.0.4

    Hi all. Don't know if this is the right place to post this, but any way.... This is my current configuration: - Oracle Database 10.2.0.4 on OL for 64 bits: [oracle@VM1 OPatch]$ ./opatch lsinventory Invoking OPatch 10.2.0.4.2 Oracle Interim Patch Inst

  • Library module: clicking on filmstrip image does not change image in loupe

    LR 3.4.1, 64 bit, Windows 7 In the library module, clicking on an image in the filstrip does not update the image viewed in the loupe view. How do I get that behavior back?

  • Very new to flash, could use some help

    Sorry the title isn't too descriptive, couldn't really think what to put there. Anyway, i'm making an 'interactive map' for a game I play. I have the map itself, if was given to me by the game developers, but what i'm trying to do is place points on

  • SAP Closed Benefit Plans

    Hi All, We have certain Benefit Plans which are closed , no more new Enrollment in this plan.But existing employees can change their benefit plan option. This plan has Plan type as that of many active plans. When i try to see this plan in Enrollment