Simple String assignment

I'm using netBeans...if that matters. I've never seen this error before while assigning content to a string. Can anyone tell me why this is happening?
textForArtist is a JLabel.
found : java.lang.String
required: com.sun.org.apache.xpath.internal.operations.String
this.artist = textForArtist.getText();
Thanks in advance.

textForArtist.getText() returns a java.lang.String object.
What type is this.artist? Looks like it's a com.sun.org.apache.xpath.internal.operations.String type, according to the error message. That isn't compatible with a java.lang.String expected type, hence the error. Did you really expect that since both class names happen to end in "String" that it would just work as if by magic?

Similar Messages

  • Simple String Compression Functions

    Hi all !
    I need two simple String compression functions, like
    String compress(String what)
    and
    String decompress(String what)
    myString.equals(decompress(compress(myString)))
    should result in true.
    Primarily I want to encode some plain text Strings so they are not too easy to read, and compression would be a nice feature here.
    I already tried the util.zip package, but that one seems to need streams, I simply need Strings.
    Any ideas ??
    thx
    Skippy

    It does not do any compression, in fact it does
    expansion to better encrypt the string (about 50%).How does that work? You want encryption to
    decrease entropy.Why in the world do you say that, pjt33? What a very odd statement indeed. I sure hope you don't work in security, or I do hope you work in security if I'm a bad guy, or a competitor.
    Let's say you had a 6-character string you wanted to encrypt.
    Well, if you didn't increase the entropy, any 6-character plaintext string would have a 6-character encoded equivalent. And if you decreased entropy (e.g. coding the most commonly used words to shorter strings,) it gets even easier to decrypt.
    Presumably there would be no hash collisions, after all, you want this to be reversible.
    Hash collisions decrease entropy too, and, by doing so, make it easier to find a plaintext string that happens to hash to a certain value. This is a Bad Thing.
    Now, to decode this, the Bad Guy only has to consider the set of 6-character strings and their hash values. You could even precalculate all of the common dictionary words, and everything with common letters and punctuation, making decryption virtually instantaneous. Especially if you had decreased the entropy in the signal, making fewer things I had to try.
    But somebody who increased the entropy of their signal by adding random bits and increasing the encrypted size of the message to, say, 64 characters, would make it a lot harder to decrypt.
    The ideal encryption system is pure noise; pure randomized entropy. An indecipherable wall of 0 and 1 seemingly generated at random. Statistical methods can't be used against it; nothing can be deciphered from it; it's as decipherable and meaningless as radio hiss. Now that's encryption!

  • UTF-8 working in JSP not in JavaBean (when assigned to a simple String)

    I am struggling with for last few hours. All I am doing is
    public class Text extends Object implements Serializable {
    public static Hashtable ht = new Hashtable();
    public static void initL10N(){
    public static String xyz = "आपके";
    ht.put("hindi",xyz);
    in a JavaBean and trying to access the string in a Jsp Out.jsp as <%=Text.ht.get("hindi")%> I am getting Junk characters.
    But to my surprise: If I do that in a jsp: as (since I declared the ht as public static it's accessable to the new JSP called L10NInit.jsp
    <%
    Text.ht.put("hindi2","&#2310;&#2346;&#2325;&#2375;")l
    %>
    and execute the Out.jsp and then execute my orginal jsp to get the string as <%=Text.ht.get("hindi2")%> it displays beautifully.
    I tried every thing else before turning to this forum. Please help.
    Environment: NetBeans5.5

    In the JSP also I am assigining straignt hindi chars (some how forum displayed entities) as &#2357;&#2376;&#2358;&#2381;&#2357;&#2367;&#2325;

  • Weird case of simple parameter assignment

    Hi, Guys !
    Here's some challenge for you. I have a Package where one of the Functions used for Error_logging. It works fine, except rarely it gives an Error :
    ORA-06512: at "CORE_PKG", line 295
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    272 PROCEDURE ERR_HANDLER_PRC
    273 (iERR_CODE IN NUMBER,
    274 oRETURN_CODE OUT NUMBER,
    275 oRETURN_MSG OUT ERROR_MSG_BV.MSG_TEXT%TYPE,
    276 iUSE_SQLERRM IN BOOLEAN DEFAULT TRUE) IS
    277
    278 vMSG_REC ERROR_MSG_BV%ROWTYPE := MSG_ROW_FNC (iERR_CODE); -- This Function selects 0 or 1 row based on passed Error code from Table of standard messages (just 33 rows)
    279
    280 BEGIN
    281
    282 IF vMSG_REC.MSG_TEXT IS NULL OR vMSG_REC.RETURN_CODE IS NULL THEN
    283 vMSG_REC.RETURN_CODE := iERR_CODE;
    284 vMSG_REC.MSG_TEXT := SQLERRM (iERR_CODE);
    285 END IF;
    286
    287 oRETURN_CODE := vMSG_REC.RETURN_CODE;
    288 oRETURN_MSG := vMSG_REC.MSG_TEXT;
    289
    290 EXCEPTION
    291
    292 WHEN OTHERS THEN
    293
    294 oRETURN_CODE := vMSG_REC.RETURN_CODE;
    295 oRETURN_MSG := vMSG_REC.MSG_TEXT;
    296
    297 INSERT_ERROR_LOG_PRC ('CORE_PKG', 'ORACLE', SQLCODE, SQLERRM, 'ERR_HANDLER_PRC',
    298 'Execution Block of ERR_HANDLER_PRC');
    299
    300 END ERR_HANDLER_PRC;
    At line 295 - just a simple assignment of one field (which is VARCHAR2 (512) <- longest Oracle SQLERRM string) belonging to a ROWTYPE variable. But that's happening inside error handler which means that initial
    error occur on Line 284 or 288. On those lines
    also similar assignments. I checked all parameters, variables, %types and %rowtypes and they all
    VARCHAR2(512) - exactly what are suppose to be. Longest string selected from Table of standard messages into %rowtype.msg_text is 97 characters (eventhough it can hold up to 512).
    So my question is HOW in the world is possible that Buffer is too small If it's SAME length that variable ???
    (and actual string less then 512)
    Any Ideas anybody ?
    Thanx ! ( Please let me know If anything is unclear )

    Thanx, Rich. I understand what you're saying and I was able to re-create error in Anonymous block which calls
    ERR_LOG_HANDLER_PRC and which call ERR_HANDLER_PRC that raises an Error.
    DECLARE
    STATUS ERROR_LOG_BV.ERROR_CODE%TYPE;
    STATUS_MSG VARCHAR2(20); <-- this declaration causes 'Buffer too small' error
    BEGIN
    PENSKE_CORE_PKG.ERR_LOG_HANDLER_PRC (SQLCODE, SQLERRM, STATUS, STATUS_MSG, TRUE, 'ORACLE',
    'ANONYMOUS_BLOCK', 'TEST_CALL');
    END;
    But this code executes fine:
    DECLARE
    STATUS ERROR_LOG_BV.ERROR_CODE%TYPE;
    STATUS_MSG ERROR_LOG_BV.ERROR_DESC%TYPE;
    BEGIN
    PENSKE_CORE_PKG.ERR_LOG_HANDLER_PRC (SQLCODE, SQLERRM, STATUS, STATUS_MSG, TRUE, 'ORACLE',
    'ANONYMOUS_BLOCK', 'TEST_CALL');
    END;
    But that's a testing code. In the real code I checked all Programs calling that routine, and all
    OUT parameters and variables declared dynamically like :
    vERR_CODE ERROR_LOG_BV.ERROR_CODE%TYPE;
    vERR_MSG ERROR_LOG_BV.ERROR_DESC%TYPE;
    So I don't know how is that possible ?

  • Write a simple string to a file.

    I have a string that is formatted with new lines that I want to write to a file as is. I have not been able to create a File Partner Link that can successfully write the content.
    The opaque approach creates an empty file.
    I have tried defining a new schema as a string, a delimited and a fixed length and the closest I have come is getting the last line written with fixed length.
    This is the input schema. I want to write the file element. The complex_child element contains values I would use to build the file name.
    <xs:complexType name="complex_parent_type">
    <xs:sequence>
    <xs:element name="complex_child" type="ns1:complex_child_type"/>
    <xs:element name="file" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    Anybody have any success? I would think this should be a simple process. We would prefer not to use embedded Java.
    Thanks,
    Wes.

    Hi Wes,
    You could try using this schema:
    <?xml version="1.0" ?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
    targetNamespace="..."
    xmlns:tns="..."
    elementFormDefault="qualified" attributeFormDefault="unqualified"
    nxsd:encoding="US-ASCII" nxsd:stream="chars"
    nxsd:version="NXSD" >
    <xsd:element name="file" type="xsd:string" nxsd:style="terminated"
                                  nxsd:terminatedBy="${eof}">
    </xsd:element>
    </xsd:schema>
    You could copy over the contents of the string that you want to write out into the element above and then use the "invoke" on a file adapter PL to write it out.
    Regards,
    Narayanan

  • DB Adapter 902 binding exception while passing parameters for simple string

    Hi,
    I have an PlSQL API with two input paramters of string type... But this is only started after XML validation TRUE on the BPM server.
    The error is
    <bindingFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="code"><code>902</code>
    </part><part name="detail"><detail>
    Internal Exception: java.sql.SQLException: ORA-00902: invalid datatype
    Error Code: 902</detail>
    </part><part name="summary"><summary>file:/oracle/product/10.1.3/soa/bpel/domains/Website/tmp/.bpel_BPELProcess1_1.0_c64929dfd2dacf95db3c9da081c1797d.tmp/callingAPI.wsdl [ callingAPI_ptt::callingAPI(InputParameters,OutputParameters) ] - WSIF JCA Execute of operation 'callingAPI' failed due to: Error while trying to prepare and execute an API.
    An error occurred while preparing and executing the XXRBA.XXRBA_WEB_ADAPTER.FETCH_CUSTOMERS API. Cause: java.sql.SQLException: ORA-00902: invalid datatype
    [Caused by: ORA-00902: invalid datatype
    ; nested exception is:
         ORABPEL-11811
    Error while trying to prepare and execute an API.
    An error occurred while preparing and executing the XXRBA.XXRBA_WEB_ADAPTER.FETCH_CUSTOMERS API. Cause: java.sql.SQLException: ORA-00902: invalid datatype
    [Caused by: ORA-00902: invalid datatype
    Check to ensure that the API is defined in the database and that the parameters match the signature of the API. Contact oracle support if error is not fixable.
    </summary>
    </part></bindingFault>
    The input XSD parameters in BPEL input
    <element name="input" type="string"/>
    The input XSD parameters in ADAPTER
    <element name="P_WEB_ACCOUNT" type="string" db:index="1" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
    <element name="P_SOLICITED_ONLY" type="string" db:index="2" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
    The assignment I am doing in the .bple file is
    <assign name="Assign_1">
    <copy>
    <from expression="bpws:getVariableData('inputVariable','payload','/client:BPELProcess1ProcessRequest/client:input')"/>
    <to variable="Invoke_1_callingAPI_InputVariable" part="InputParameters"
    query="/ns2:InputParameters/ns2:P_WEB_ACCOUNT"/>
    </copy>
    <copy>
    <from expression="string('o')"/>
    <to variable="Invoke_1_callingAPI_InputVariable" part="InputParameters"
    query="/ns2:InputParameters/ns2:P_SOLICITED_ONLY"/>
    </copy>
    </assign>
    --Khaleel                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    You have an attribute type in an object service that is supposed to be numeric, but when reading form the database it seems that is retrieving a non-numeric content...
    Cheers,
    Vlad

  • Accessing String assigned in a JSP from a Servlet?

    Hello all, I was wondering if there is a way to access a String object that was assigned by an HttpSession object in a JSP from a Servlet. What happens is, in my application a user logs in, an HttpSession object is instantiated and all of the user credentials are assigned within a JSP like:
    HttpSession httpSession = request.getSession( false );
    String userName = httpSession.getAttribute("userName);
    ...{code}
    Next, I have a Servlet (which is really just a Proxy to a different server), that I need to log some information with, namely the userName String. Is there a way I can access that String without instantiating another HttpSession object? Because when the timeout occurs (or when the user clears his cache I have found), the HttpSession becomes invalidated (even if I use  +HttpSession#getSession( true )+) and the +HttpSession#getAttribute+ call fails (userName is just null). So is this possible to do?
    Thanks in advance!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    dnbphysicist wrote:
    I understand you cannot recover attributes from a dead session, this is why I wanted to be able to access a variable that is pulled from the Session immediately after login so I can still get to it even once the session is dead.
    Normally a session doesn't go dead after login.
    I imagine that by using application scope the app would confuse the userName with other users that are logged in?Certainly. It was just an example. But your data clearly belongs in the session, so just keep it in the session. If the session get invalidated while it should not get invalidated, then your problem truly lies somewhere else.
    I am definitely not arguing you latter point either :) A lot of this code I inherited unfortunately from previous developers and we are in desperate need of a redesign.I wish you much luck with that.

  • Simple string / bytes problem

    Hi
    I'm basically trying to simulate DES in java from scratch (so no use of existing API's or anything). I've got a basic idea of how DES works (use of a feistel cipher).
    So to start off I'm trying to get the bytes of a string with this simple program:
    public class Test {
         public static void main(String[] args) {     
              String testString = "hello";
              System.out.println(testString.getBytes());
    }The output consists of some characters (namely numbers, letters and 1 special character).
    But when I change the variable testString to some other String, complie and run I still get the same output even though the String is different. Also why are there 9 characters for a String thats only 5 characters long?
    Thanks

    When you use System.out.println( something ) it uses to the toString() method of the object referenced by 'something'. When the something is an array such as an array of bytes the toString() methed returns a pseudo reference to the array which in no way reflects the content of the array.
    If you just want to see the content of the array then use Arrays.toString(something) to generate a String representation of the content of the array.
    Also, the use of String.getBytes() will convert the String to bytes using your default character encoding. This is rarely what you want since the result may depend on which platform you are working on. In my view, the safest and best approach is to explicitly define the encoding and since it will encode ALL characters one can throw at it I always use utf-8. So, to convert a String to bytes I would usebyte[] bytesOfString = "your string".getBytes("utf-8");and to convert them back to a String I would useString yourString = new String(bytesOfString,"utf-8");One final point, do not assume that an apparently random array of bytes such as one gets from DES encryption can be converted to a String using the above. In general it can't because not all bytes and byte sequences are valid for a particular character encoding. If you absolutely have to have a String representation then you should encode (not encrypt) the bytes using something like Base64 or Hex encoding.
    Edited by: sabre150 on Jan 27, 2008 3:04 PM

  • Im DROWNING! need help with a simple java assignment! plz someone help me!

    i need help with my java assignment, with validating a sin number. easy for must who know java. im drowning... please help!

    You will need to store each digit of the social insurance number in a field of its own. To validate the entry you will:
    1. Multiply the 2nd, 4th, 6th and 8th digit by 2.
    2. If the product of any of the four multiplications result in a value greater than 9, add the two resulting digits together to yield a single-digit response. For example 6 * 2 = 12, so you would add the 1 and the 2 to get a result of 3.
    3. Add these four calculated values together, along with the 1st, 3rd, 5th, and 7th digits of the original number.
    4. Subtract this sum from the next highest multiple of 10.
    5. The difference should be equal to the 9th digit, which is considered the check digit.
    Example of validating S.I.N. 765932546
    1st digit 7
    2nd digit (6*2 =12 1+2=) 3
    3rd digit 5
    4th digit (9*2 = 18 1+8 =) 9
    5th digit 3
    6th digit (2*2 = 4) 4
    7th digit 5
    8th digit (4*2 = 8) 8
    Total 44 next multiple of 10 is 50
    50-44 = 6 which is the 9th digit
    Therefore the S.I.N. 765932546 is Valid
    ********* SIN Validation *********
    Welcome - Please enter the first number: 120406780
    Second digit value multiplied by 2 4
    Fourth digit value multiplied by 2 8
    Sixth digit value multiplied by 2 12
    Eighth digit value multiplied by 2 16
    Value derived from 6th digit 3
    Value derived from 8th digit 7
    The total is 30
    Calculated digit is 10
    Check digit must be zero because calculated value is 10
    The SIN 120406780 is Valid
    this is my assignemtn this is what i have! i dont know where to start! please help me!
    /*     File:     sinnumber.java
         Author:     Ashley
         Date:     October 2006
         Purpose: Lab1
    import java.util.Scanner;
    public class Lab1
              public static void main(String[] args)
                   Scanner input = new Scanner(System.in);
                   int sin = 0;
                   int number0, number1, number2, number3, number4, number5, number6, number7, number8;
                   int count = 0;
                   int second, fourth, sixth, eighth;
                   System.out.print("\t\n**********************************");
                   System.out.print("\t\n**********SIN Validation**********");
                   System.out.print("\t\n**********************************");
                   System.out.println("\t\nPlease enter the First sin number: ");
                   sin = input.nextInt();
                   count = int.length(sin);     
                   if (count > 8 || count < 8)
                   System.out.print("Valid: ");
         }

  • How to get String assigned value

    Hi,
    As String is immutable and we know that the value of string is not changable.
    eg: String abc= new String();
    abc = "INDIA";
    system.out.println("1st abc : "+abc);
    abc=abc.toLowerCase();
    system.out.println("2nd abc : "+abc);
    As we know as string is immutable the value for the 2nd abc gives us india.As 2nd abc creates a new instance object stores in new memory location.
    Then y string is called immutable.It means the value is getting changed.
    Is their a way to retrive my original value or first assigned value for abc i.e INDIA.
    Thanks
    LeoSun.

    LeoSun wrote:
    Then y string is called immutable.It means the value is getting changed.No, it is not changed, you just assign a new value to your variable 'abc'.
    String abc = "INDIA";
             +-----------+
    abc -----+-> "INDIA" |
             +-----------+
    abc = abc.toLowerCase();
             +-----------+
    abc ---+ |   "INDIA" |
           | |           |
           +-+-> "india" |    
             +-----------+As you see, "INDIA" is not changed, a new String, "india" is created where your variable 'abc' points to.
    Is their a way to retrive my original value or first assigned value for abc i.e INDIA.
    ...Once you change the value of 'abc' (and there exists no reference to it's old value), then no, it's not possible.
    Why would you want that?

  • String assignment ?

    Hi,
    in the following code:
    public class Test {
    public static void main(String[] args) {
    String s = new String("Welcome to Java");
    Object o = s;
    String d = (String)o;
    System.out.println(o + s + d);
    Both strings and the object are referring to the same string object., and the println shows 3 "Welcome to Java" 's. I don't understand exactly why this is so? I was hoping someone might be able to explain it to me.
    Thanks!
    Jimbo
    think

    First of all, I was under the impression that when
    you declare a string variable and use the new keyword
    that what you were doing was constructing a String
    object (to which you can apply the functions of the
    String class). Yes. But you don't NEED to do new String(...) to get a String object. Usually you just assign it to a String literal (s = "abc";) or get it from a config file or user input, or call some object's toString() method.
    I am unclear what is actually happening when the code
    "Object o = " was used. Is the Object class the
    super (or parent) class, so that a String is
    automatically in the Object class because it is its
    parent? Correct.
    I take it that after that line of code, we
    have two reference variables pointing at the
    String......and then the second "String = " statement
    is just making another reference to the same String.Correct.
    With the family example you gave me.....applying it
    this string.....the three variables are just three
    different points of reference to the same string. Correct.
    As far as why I thought it might be any
    different....earlier on in the class
    we had code that went kinda like this:
    String s = "me";
    String t = "you";
    s = t;
    I guess in this case we lost our reference to the
    String "me", so if we println s and t we get two
    "you" 's.Correct. So, why would printing a + b + c (or whatever your variables were in the initial post) produce anything but three of the same thing? I still don't know what you expected or why.
    I guess I was getting this all
    confused....probably making it more difficult than it
    actually is...but I have a lot coming at me at
    once.....Actually, it sounds like you have a better handle on how Java's reference variables work than most beginners. The idea that the variable holds a reference, not an object, and that assignment doesn't copy an object, comes hard to some people. You sound like you understand that part of it.

  • Havin probs drawing a simple string

    hi 2 all
    i've got this simple applet,but it doesn't really what i want!i only see a gry rect!but he has to draw a string!
    import java.applet.*;
    import java.net.*;
    import java.io.*;
    import java.awt.*;
    public class CCounter1 extends Applet {
    Font anzeiger;
    public void init() {
    anzeiger=new Font("Arial",Font.BOLD,16);
    public String readFile(String f) {
    try {
    String zahl1="";
    String aLine = "";
    URL source = new URL(getCodeBase(), f);
    BufferedReader br =new BufferedReader(new InputStreamReader(source.openStream()));
    while(null != (aLine = br.readLine()))
    zahl1.concat(zahl1);
    br.close();
    return aLine;
    catch(Exception e) {
    e.printStackTrace();
    return null;
    public void paint(Graphics g){
    setBackground(Color.gray);
    g.setColor(Color.white);
    setFont(anzeiger);
    g.fillRect(100,100,100,100);
    g.drawString(readFile("besucher.hansi"),10,20);
    g.drawString("Hallo",200,200);

    You set the color to white... fill the area and then paint a string (with the same white color)
    first... set a color... fill it... then set another color... draw your string... done
    Grtz David

  • Simple String Encryption

    HI,
    I have been serching around on here for encyption methods but there seems to be soo many i not sure which ones would be good for me.
    All i want to do is encypt and decrypt a String record. The encryption doesnt have to be particulary safe but must work for all possible charaters. Basically i am saving records to a text file and i dont want someone to be able to open the text file and read the contents.
    I would like to make it as simple as possible so i can just use it like:
    String record = "This is the record";
    // Encrypted Record
    String encRecord = Encryption.encrypt(record);
    // Decripted Record
    String decRecord = Encryption.decrypt(record);Can anyone stear me in the right direction or give me some sample code i can study.
    Thank you in advance
    ed

    Here is simple encryption routine that I just wrote that I bet would keep someone
    stumped for a while.
    * This is a simple encryption class that uses simple character substitution.
    * To keep the pattern from being obvious the shift factor is a function of the current character's
    * position in the source string. This makes sure that all letters aren't encrypted to the same value.
    * Usage: To encrypt a string just pass it to the encrypt method.
    *         String encryptedString = Encryptor.encrypt("Some string.");
    *        To decrypt a string just pass the encrypted string to the decrypt method.
    *         String decryptedString = Encryptor.decrypt(encryptedString);
    class Encryptor
      static final byte [] shiftFactor = {2,5,7,9,13,17,19};
      static final int modulo = shiftFactor.length;
      static public String encrypt(String s)
         char [] ba = s.toCharArray();
         for (int i = 0; i < ba.length; i++)
              ba[i] += shiftFactor[i%modulo];
        return new String(ba);
      static public String decrypt(String s)
         char [] ba = s.toCharArray();
         for (int i = 0; i < ba.length; i++)
              ba[i] -= shiftFactor[i%modulo];
         return new String(ba);
      public static void main(String [] args)
         String [] test = {"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz,./<>?;':\"[]{}-=_+!@#$%^&*()`~",
                           "Now is the time for all good men \n to come to the aid of their country."};
        for (int i = 0; i < test.length; i++)
              System.out.println(test);
              String encrypted = Encryptor.encrypt(test[i]);
              System.out.println(encrypted);
              System.out.println(Encryptor.decrypt(encrypted) + "\n");

  • Method to Format a string column containing HTML tags as simple string.

    Hello,
    I am working with formating a string column which holds Html tags.
    I want to remove these tags from the actual data which has to be shown on the BI Publisher report.
    Can you suggest how can we format this in the DataSet designer of BI publisher so that my data is recognised on the Layout designer.
    I have been trying to create an expression using the "Add Element by Expression" option to format this html tag data as normal string without the tags.
    Can you suggest if this is the correct method to do this.
    I found this below code being used in an existing DateSet but i am not able to recreate a similar formating on this kind of data column.
    <![CDATA' || '['|| TO_CLOB(SUCCESS_CRITERIA) || ']' || ']>
    Kindly suggest if you have any idea on the above mentioned issue.
    Thanks,
    Shweta

    And read this:
    Navigate yourself around pitfalls related to the Runtime.exec() method
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Simple string optimization question

    ABAPpers,
    Here is the problem description:
    In a SELECT query loop, I need to build a string by concatenating all the column values for the current row. Each column is represented as a length-value pair. For example, let's say the current values are:
    Column1 (type string)  : 'abc          '
    Column2 (type integer) : 7792
    Column3 (type string)  : 'def                    '
    The resulting string must be of the form:
    0003abc000477920003def...
    The length is always represented by a four character value, followed by the actual value.
    Note that the input columns may be of mixed types - numeric, string, date-time, etc.
    Given that data is of mixed type and that the length of each string-type value is not known in advance, can someone suggest a good algorithm to build such a result? Or, is there any built-in function that already does something similar?
    Thank you in advance for your help.
    Pradeep

    Hi,
    At the bottom of this message, I have posted a program that I currently wrote. Essentially, as I know the size of each "string" type column, I use a specific function to built the string. For any non-string type column, I assume that the length can never exceed 25 characters. As I fill 255 characters in the output buffer, I have to write the output buffer to screen.
    The reason I have so many functions for each string type is that I wanted to optimize concatenate operation. Had I used just one function with the large buffer, then "concatenate" statement takes additional time to fill the remaining part of the buffer with spaces.
    As my experience in ABAP programming is limited to just a couple of days, I'd appreciate it if someone can suggest me a better way to deal with my problem.
    Thank you in advanced for all your help. Sorry about posting such a large piece of code. I just wanted to show you the complexity that I have created for myself :-(.
    Pradeep
    REPORT ZMYREPORTTEST no standard page heading line-size 255.
    TABLES: GLPCA.
    data: GLPCAGL_SIRID like GLPCA-GL_SIRID.
    data: GLPCARLDNR like GLPCA-RLDNR.
    data: GLPCARRCTY like GLPCA-RRCTY.
    data: GLPCARVERS like GLPCA-RVERS.
    data: GLPCARYEAR like GLPCA-RYEAR.
    data: GLPCAPOPER like GLPCA-POPER.
    data: GLPCARBUKRS like GLPCA-RBUKRS.
    data: GLPCARPRCTR like GLPCA-RPRCTR.
    data: GLPCAKOKRS like GLPCA-KOKRS.
    data: GLPCARACCT like GLPCA-RACCT.
    data: GLPCAKSL like GLPCA-KSL.
    data: GLPCACPUDT like GLPCA-CPUDT.
    data: GLPCACPUTM like GLPCA-CPUTM.
    data: GLPCAUSNAM like GLPCA-USNAM.
    data: GLPCABUDAT like GLPCA-BUDAT.
    data: GLPCAREFDOCNR like GLPCA-REFDOCNR.
    data: GLPCAAWORG like GLPCA-AWORG.
    data: GLPCAKOSTL like GLPCA-KOSTL.
    data: GLPCAMATNR like GLPCA-MATNR.
    data: GLPCALIFNR like GLPCA-LIFNR.
    data: GLPCASGTXT like GLPCA-SGTXT.
    data: GLPCAAUFNR like GLPCA-AUFNR.
    data: data(255).
    data: currentPos type i.
    data: lineLen type i value 255.
    data len(4).
    data startIndex type i.
    data charsToBeWritten type i.
    data remainingRow type i.
    SELECT GL_SIRID
    RLDNR
    RRCTY
    RVERS
    RYEAR
    POPER
    RBUKRS
    RPRCTR
    KOKRS
    RACCT
    KSL
    CPUDT
    CPUTM
    USNAM
    BUDAT
    REFDOCNR
    AWORG
    KOSTL
    MATNR
    LIFNR
    SGTXT
    AUFNR into (GLPCAGL_SIRID,
    GLPCARLDNR,
    GLPCARRCTY,
    GLPCARVERS,
    GLPCARYEAR,
    GLPCAPOPER,
    GLPCARBUKRS,
    GLPCARPRCTR,
    GLPCAKOKRS,
    GLPCARACCT,
    GLPCAKSL,
    GLPCACPUDT,
    GLPCACPUTM,
    GLPCAUSNAM,
    GLPCABUDAT,
    GLPCAREFDOCNR,
    GLPCAAWORG,
    GLPCAKOSTL,
    GLPCAMATNR,
    GLPCALIFNR,
    GLPCASGTXT,
    GLPCAAUFNR) FROM GLPCA
    perform BuildFullColumnString18 using GLPCAGL_SIRID.
    perform BuildFullColumnString2 using GLPCARLDNR.
    perform BuildFullColumnString1 using GLPCARRCTY.
    perform BuildFullColumnString3 using GLPCARVERS.
    perform BuildFullColumnString4 using GLPCARYEAR.
    perform BuildFullColumnString3 using GLPCAPOPER.
    perform BuildFullColumnString4 using GLPCARBUKRS.
    perform BuildFullColumnString10 using GLPCARPRCTR.
    perform BuildFullColumnString4 using GLPCAKOKRS.
    perform BuildFullColumnString10 using GLPCARACCT.
    perform BuildFullColumnNonString using GLPCAKSL.
    perform BuildFullColumnNonString using GLPCACPUDT.
    perform BuildFullColumnNonString using GLPCACPUTM.
    perform BuildFullColumnString12 using GLPCAUSNAM.
    perform BuildFullColumnNonString using GLPCABUDAT.
    perform BuildFullColumnString10 using GLPCAREFDOCNR.
    perform BuildFullColumnString10 using GLPCAAWORG.
    perform BuildFullColumnString10 using GLPCAKOSTL.
    perform BuildFullColumnString18 using GLPCAMATNR.
    perform BuildFullColumnString10 using GLPCALIFNR.
    perform BuildFullColumnString50 using GLPCASGTXT.
    perform BuildFullColumnString12 using GLPCAAUFNR.
    ENDSELECT.
    if currentPos > 0.
      move '' to datacurrentPos.
      write: / data.
    else.
      write: / '+'.
    endif.
    data fullColumn25(29).
    data fullColumn1(5).
    Form BuildFullColumnString1 using value(currentCol). 
      len = STRLEN( currentCol ).
      concatenate len currentCol into fullColumn1.
      data startIndex type i.
      data charsToBeWritten type i.
      charsToBeWritten = STRLEN( fullColumn1 ).
      data remainingRow type i.
      do.
        remainingRow = lineLen - currentPos.
        if remainingRow > charsToBeWritten.
          move fullColumn1+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          currentPos = currentPos + charsToBeWritten.
          exit.
        endif.
        if remainingRow EQ charsToBeWritten.
          move fullColumn1+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          write: / data.
          currentPos = 0.
          exit.
        endif.
        move fullColumn1+startIndex(remainingRow) to
            data+currentPos(remainingRow).
        write: / data.
        startIndex = startIndex + remainingRow.
        charsToBeWritten = charsToBeWritten - remainingRow.
        currentPos = 0.
      enddo.
    EndForm.
    data fullColumn2(6).
    Form BuildFullColumnString2 using value(currentCol). 
      len = STRLEN( currentCol ).
      concatenate len currentCol into fullColumn2.
      data startIndex type i.
      data charsToBeWritten type i.
      charsToBeWritten = STRLEN( fullColumn2 ).
      data remainingRow type i.
      do.
        remainingRow = lineLen - currentPos.
        if remainingRow > charsToBeWritten.
          move fullColumn2+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          currentPos = currentPos + charsToBeWritten.
          exit.
        endif.
        if remainingRow EQ charsToBeWritten.
          move fullColumn2+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          write: / data.
          currentPos = 0.
          exit.
        endif.
        move fullColumn2+startIndex(remainingRow) to
            data+currentPos(remainingRow).
        write: / data.
        startIndex = startIndex + remainingRow.
        charsToBeWritten = charsToBeWritten - remainingRow.
        currentPos = 0.
      enddo.
    EndForm.
    data fullColumn3(7).
    Form BuildFullColumnString3 using value(currentCol). 
    EndForm.
    data fullColumn4(8).
    Form BuildFullColumnString4 using value(currentCol). 
    EndForm.
    data fullColumn50(54).
    Form BuildFullColumnString50 using value(currentCol). 
    EndForm.
    Form BuildFullColumnNonString using value(currentCol). 
      move currentCol to fullColumn25.
      condense fullColumn25.     
      len = STRLEN( fullColumn25 ).
      concatenate len fullColumn25 into fullColumn25.
      data startIndex type i.
      data charsToBeWritten type i.
      charsToBeWritten = STRLEN( fullColumn25 ).
      data remainingRow type i.
      do.
        remainingRow = lineLen - currentPos.
        if remainingRow > charsToBeWritten.
          move fullColumn25+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          currentPos = currentPos + charsToBeWritten.
          exit.
        endif.
        if remainingRow EQ charsToBeWritten.
          move fullColumn25+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          write: / data.
          currentPos = 0.
          exit.
        endif.
        move fullColumn25+startIndex(remainingRow) to
            data+currentPos(remainingRow).
        write: / data.
        startIndex = startIndex + remainingRow.
        charsToBeWritten = charsToBeWritten - remainingRow.
        currentPos = 0.
      enddo.
    EndForm.

Maybe you are looking for